1 of 23

Dr. Harpreet Singh

Head, PG Department of Bioinformatics,

Hans Raj Mahila Maha Vidyalaya,

Jalandhar, Punjab, India

e-module

Introduction to the R Programing Interface

2 of 23

What is R

  • Software for Statistical Data Analysis
  • Based on S
  • Programming Environment
  • Interpreted Language
  • Data Storage, Analysis, Graphing
  • Free and Open Source Software

Introduction

3 of 23

  • Current Version: R-4.3.1
  • Comprehensive R Archive Network:

http://cran.r-project.org

  • Binary source codes
  • Windows executables
  • Compiled RPMs for Linux
  • Can be obtained on a CD

Obtaining R

4 of 23

The R Project

5 of 23

Downloading R from different mirror sites

6 of 23

Different R distributions for Windows, Linux, macOS etc.

7 of 23

Different R distributions

8 of 23

Downloading & Installing R for Windows

9 of 23

Downloading & Installing R for Windows

10 of 23

Downloading & Installing R for Windows

11 of 23

Downloading & Installing R for Windows

12 of 23

Downloading & Installing R for Unix/Linux

$ tar –zxvf “filename.tar.gz”

$ cd filename

$ ./configure

$ make

$ make check

$ make install

13 of 23

Windows, Double-click on Desktop Icon

Linux, type R at command prompt

$ R

Starting R

14 of 23

  • Strengths
    • Free and Open Source
    • Strong User Community
    • Highly extensible, flexible
    • Implementation of high end statistical methods
    • Flexible graphics and intelligent defaults
  • Weakness
    • Steep learning curve
    • Slow for large datasets

Strengths and Weaknesses

15 of 23

  • Highly Functional
    • Everything done through functions
    • Strict named arguments
    • Abbreviations in arguments OK (e.g. T for TRUE)
  • Object Oriented
    • Everything is an object
    • <-” is an assignment operator
    • “X <- 5”: X GETS the value 5

Basics

16 of 23

  • From Documentation:
    • ?WhatIWantToKnow
    • help(“WhatIWantToKnow”)
    • help.search(“WhatIWantToKnow”)
    • help.start()
    • getAnywhere(“WhatIWantToKnow”)
    • example(“WhatIWantToKnow”)
  • Documents: “Introduction to R”
  • Active Mailing List
    • Archives
    • Directly Asking Questions on the List

Getting Help in R

17 of 23

  • Supports virtually any type of data
  • Numbers, characters, logicals (TRUE/ FALSE)
  • Arrays of virtually unlimited sizes
  • Simplest: Vectors and Matrices
  • Lists: Can Contain mixed type variables
  • Data Frame: Rectangular Data Set

Data Structures

18 of 23

Linear

Rectangular

All Same Type

VECTORS

MATRIX*

Mixed

LIST

DATA FRAME

Data Structure in R

19 of 23

  • Directly in the Windowing System (Console)
  • Using Editors
    • Notepad, WinEdt, Tinn-R: Windows
    • Xemacs, ESS (Emacs speaks Statistics)
  • On the Editor:
    • source(“filename.R”)
    • Outputs can be diverted by using
      • sink(“filename.Rout”)

Running R

20 of 23

The R interface for Windows

21 of 23

R Working Area

This is the area where all commands are issued, and non-graphical outputs observed when run interactively

22 of 23

https://favtutor.com/blogs/r-programming-projects

23 of 23

Thanks