SlideShare uma empresa Scribd logo
1 de 27
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

Mais conteúdo relacionado

Mais procurados

ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)
Makoto Yamazaki
 

Mais procurados (8)

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

Destaque

Destaque (13)

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

Semelhante a R Intro Workshop

Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
Software Guru
 

Semelhante a R Intro Workshop (20)

Database queries
Database queriesDatabase queries
Database queries
 
Four Languages From Forty Years Ago
Four Languages From Forty Years AgoFour Languages From Forty Years Ago
Four Languages From Forty Years Ago
 
Programming in R
Programming in RProgramming in R
Programming in R
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
 
Presentation R basic teaching module
Presentation R basic teaching modulePresentation R basic teaching module
Presentation R basic teaching module
 
The Great Scala Makeover
The Great Scala MakeoverThe Great Scala Makeover
The Great Scala Makeover
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Getting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commitsGetting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commits
 
R environment
R environmentR environment
R environment
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
Class 10 Arrays
Class 10 ArraysClass 10 Arrays
Class 10 Arrays
 
Java introduction
Java introductionJava introduction
Java introduction
 
Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship group
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)
 

Mais de Saad Chahine

Research Literacy GEDU6170 MSVU
Research Literacy GEDU6170 MSVUResearch Literacy GEDU6170 MSVU
Research Literacy GEDU6170 MSVU
Saad Chahine
 
Saad Chahine Thesis
Saad Chahine Thesis Saad Chahine Thesis
Saad Chahine Thesis
Saad Chahine
 

Mais de Saad Chahine (16)

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

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 

R Intro Workshop