SlideShare a Scribd company logo
Intro Workshop
Saad Chahine, PhD.
May 26, 2014
What is R?
“R is a language and environment for statistical computing and
graphics… similar to the S language and environment which was
developed at Bell Laboratories… by John Chambers and colleagues…”
“R is available as Free Software under the terms of the Free Software
Foundation's GNU General Public Licenses in source code form. It
compiles and runs on a wide variety of UNIX platforms and similar
systems (including FreeBSD and Linux), Windows and MacOS.”
http://www.r-project.org/
Getting
Started
• Download and
launch R
• Type help()
press enter
Calculator
‘>’ is the prompt line
Try: 3+5
Try: 3-5
Try: 3/5
Try: 3*5
Try: sqrt(5)
Try: sum (1,3,5)
Logic
‘>’ is the prompt line
Try: 3<5
Try: 3>5
Try: 3+5==8
Try: 3+5==9
Variables
‘<-’ assigns a value
Try: x<-24
Try: x
Try: x/2
Try: x
Try: x<-“hello world”
Try: x
Try: x<-T
Try: x
Menu Bar
• Saving your documents
• Working directories getwd()
• Saving workspace
Help Example
Try: help(ave)
Try: help(mean)
Try: help(mode)
Try: help(median)
Try: help(sd)
Try: help(t.test)
Try: help(anova)
Try: example(ave)
Try: example(mean)
Try: example(mode)
Try: example(median)
Try: example(sd)
Try: example(t.test)
Try: example(anova)
Vectors
Try: c(3,5,7)
Try: c(‘s’,’a’,’a’,’d’)
Try: 3:7
Try: seq(3,7)
Try: seq(3,7,0.25)
Try: 7:3
Try: name <-c(‘s’,’a’,’a’,’d’)’
Try: name [3]
Try: name [3] <- ‘d’
Try: name [4] <- ‘e’
Try: name
Vectors Names
Try: ranks <- 1:3
Try: names (ranks) <- c(“1st”,”2nd”,”3rd”, )
Try: ranks
Try: ranks [first]
Try: ranks [3] <-4
Try: scoRes <- c(450,578,502)
Try: barplot(scoRes)
Try: names(scoRes) <- c(“Bob”, “Marry”, “Jane”)
Try: barplot (1:200)
Matrices
Try: matrix(0,6,7)
Try: a<-1:42
Try: print (a)
Try: matrix(a,6,7)
Try: seats <- 1:20
Try: dim(seats) <- c(2,10)
Try: print (seats)
Access Values
Try: print(seats)
Try: seats[2,3]
Try: seats[2,]
Try: seats[1,]
Try: seats[,3]
Try: seats[,5:9]
Matrix
Try: MATD <-matrix(1:6,2)
Try: MATE <-matrix(c(rep(1,3), rep(2,3)), 2, byrow=T)
Try: MATE+MATD
Try: MATD+10
Try: MATD-10
Try: MATD+10
Try: MATD
Try: MATE-MATE
Try: MATD-MATE
Try: solve(MATD[,2:3])
Try: t(MATE)
Try: MATD %*% t(MATE)
Try: MATD*100
Try: MATD/MATE
Factors
Try: data = c(1,2,2,3,1,3,2,2,3,3,3,2,2,1,2)
Try: fdata=factor(data)
Try: fdata
Try: mean(data)
Import Data CSV
1. Find the file path
2. mydata <-read.table(”filepath”,
header=T, sep=“,”)
3. mydata <-read.table(”filepath”,
header=T, sep=“t”)
4. For fixed width use read.fwf
Import Data SPSS
1. Install.packages(“me
misc”)
2. library(“memisc”)
3. mydata <-
as.data.set(spss.syst
em.file('/CSSE R
Workshop/GEDU6100
dataset.sav'))
4. mydata
data.frame str
str(mydata)
data.frame summary
summary(mydata)
data.frame fix
fix(mydata)
Ways of calling your data
- Mean (mydata$MATH)
- With(mydata,
mean(MATH))
- t.test(MATH~GENDER,
data=mydata)
data.frame attach
attach(mydata)
mean(MATH)
t.test(MATH~GENDER)
Export
write.table(mydata,
“filepath/mydata.txt”)
Note: for export to exl, SAS, SPSS you may
need to use foreign package.
On your own
Try: data()
- Find a data set
and str,
summary & one
statistical
application
Useful Packages
foreign
Hmisc
prettyR
psych
ggplot2
summary(mydata
describe(mydata)
freq(mydata)
rcorr(cbind (v1,v2,v3,v4)
cor.test (v1,v2, use=“pairwise”)
Try this last one…
Try: contour(volcano)
Try: persp(volcano, expand=0.2)
Online resources
http://tryr.codeschool.com
http://www.ats.ucla.edu/stat/r/faq/inputdata_R.htm
http://www.r-project.org/
https://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html
Good Luck!
saad.chahine@msvu.ca

More Related Content

PDF
Introduction to type classes in Scala
PPTX
Dictionary in python
PPTX
Property Based Tesing
PPTX
cpp-2013 #15 Databases
PPT
Class 10 Lecture Notes
PDF
Programming in python Unit-1 Part-1
PDF
The Ring programming language version 1.7 book - Part 78 of 196
PPTX
Pa1 session 3_slides
Introduction to type classes in Scala
Dictionary in python
Property Based Tesing
cpp-2013 #15 Databases
Class 10 Lecture Notes
Programming in python Unit-1 Part-1
The Ring programming language version 1.7 book - Part 78 of 196
Pa1 session 3_slides

What's hot (8)

PDF
Scala - en bedre og mere effektiv Java?
KEY
ぐだ生 Java入門第一回(equals hash code_tostring)
PDF
The Ring programming language version 1.4 book - Part 20 of 30
PDF
Scala - en bedre Java?
PPTX
Python dictionary
PPTX
30 分鐘學會實作 Python Feature Selection
PDF
The Ring programming language version 1.3 book - Part 56 of 88
PDF
CS323: Sort - Comparison-based
Scala - en bedre og mere effektiv Java?
ぐだ生 Java入門第一回(equals hash code_tostring)
The Ring programming language version 1.4 book - Part 20 of 30
Scala - en bedre Java?
Python dictionary
30 分鐘學會實作 Python Feature Selection
The Ring programming language version 1.3 book - Part 56 of 88
CS323: Sort - Comparison-based
Ad

Viewers also liked (13)

PPTX
How to get started with R programming
PDF
Introduction to R for Data Science :: Session 2
PPTX
An Interactive Introduction To R (Programming Language For Statistics)
PDF
R programming groundup-basic-section-i
PPTX
R programming language
PDF
Executive Intro to R
PDF
Introduction to R for Data Science :: Session 1
PDF
Introduction to R Short course Fall 2016
PDF
H2O World - Intro to R, Python, and Flow - Amy Wang
PDF
Introduction to R for Data Science :: Session 3
PDF
Class ppt intro to r
PPTX
R programming
PPTX
R language tutorial
How to get started with R programming
Introduction to R for Data Science :: Session 2
An Interactive Introduction To R (Programming Language For Statistics)
R programming groundup-basic-section-i
R programming language
Executive Intro to R
Introduction to R for Data Science :: Session 1
Introduction to R Short course Fall 2016
H2O World - Intro to R, Python, and Flow - Amy Wang
Introduction to R for Data Science :: Session 3
Class ppt intro to r
R programming
R language tutorial
Ad

Similar to R Intro Workshop (20)

PPT
How to obtain and install R.ppt
PPT
Advanced Data Analytics with R Programming.ppt
PPT
Introduction to R for Data Science Technology
PPT
PPT
Slides on introduction to R by ArinBasu MD
PPT
17641.ppt
PPT
Basics of R-Progranmming with instata.ppt
PPT
introduction to R with example, Data science
PDF
R basics
PDF
Using r
KEY
Presentation R basic teaching module
PDF
Introduction to R
PPTX
Introduction to R for Learning Analytics Researchers
PPT
Rstudio is an integrated development environment for R that allows users to i...
PPT
introtorandrstudio.ppt
PPTX
Introduction to R _IMPORTANT FOR DATA ANALYTICS
PPT
Basics of R-Programming with example.ppt
PPT
Basocs of statistics with R-Programming.ppt
PPT
R-Programming.ppt it is based on R programming language
How to obtain and install R.ppt
Advanced Data Analytics with R Programming.ppt
Introduction to R for Data Science Technology
Slides on introduction to R by ArinBasu MD
17641.ppt
Basics of R-Progranmming with instata.ppt
introduction to R with example, Data science
R basics
Using r
Presentation R basic teaching module
Introduction to R
Introduction to R for Learning Analytics Researchers
Rstudio is an integrated development environment for R that allows users to i...
introtorandrstudio.ppt
Introduction to R _IMPORTANT FOR DATA ANALYTICS
Basics of R-Programming with example.ppt
Basocs of statistics with R-Programming.ppt
R-Programming.ppt it is based on R programming language

More from Saad Chahine (16)

PPTX
Quant Data Analysis
PPTX
Csse 2014 hmm presentation_ta_ed
PPTX
GEDU 6170 Reviews
PPTX
Gedu 6170 Mixed Methods Research
PPTX
Gedu 6170 tiles abstracts and intro
PPTX
Quantitative & Qualitative GEDU 6170
PPTX
Research Literacy GEDU6170 MSVU
PPT
Relationship of Competency and Global Ratings in OSCEs
PPT
A Novel Approach for Developing Rating Scales for a Practice Ready OSCE
PPT
CERA saad chahine 2013 fuzzy clusters
PPT
Ncme april 30 2013 saad chahine
PPTX
Chahine Understanding Common Study Results
PPTX
Chahine Hypothesis Testing,
PPTX
Saad Chahine ICSEI 2012
PPTX
Saad Chahine Thesis
PPTX
Saad Chahine Thesis Presentation Final
Quant Data Analysis
Csse 2014 hmm presentation_ta_ed
GEDU 6170 Reviews
Gedu 6170 Mixed Methods Research
Gedu 6170 tiles abstracts and intro
Quantitative & Qualitative GEDU 6170
Research Literacy GEDU6170 MSVU
Relationship of Competency and Global Ratings in OSCEs
A Novel Approach for Developing Rating Scales for a Practice Ready OSCE
CERA saad chahine 2013 fuzzy clusters
Ncme april 30 2013 saad chahine
Chahine Understanding Common Study Results
Chahine Hypothesis Testing,
Saad Chahine ICSEI 2012
Saad Chahine Thesis
Saad Chahine Thesis Presentation Final

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Insiders guide to clinical Medicine.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PPTX
master seminar digital applications in india
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Renaissance Architecture: A Journey from Faith to Humanism
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Insiders guide to clinical Medicine.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
master seminar digital applications in india
Sports Quiz easy sports quiz sports quiz
Supply Chain Operations Speaking Notes -ICLT Program
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
TR - Agricultural Crops Production NC III.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Abdominal Access Techniques with Prof. Dr. R K Mishra
2.FourierTransform-ShortQuestionswithAnswers.pdf

R Intro Workshop