SlideShare una empresa de Scribd logo
1 de 15
R Programming
Fundamentals
Ragia A. Ibrahim
Objectives
• How to program in R ?
• Installing and sitting working directory?
• Introduction , what is R?
Data Types ,Operations on them
• Formulating First Script .
• Visualize data
WHAT &WHY
Ross Ihaka
Robert
Gentleman
•R dialect From S
•S is a statistical programming language
•R developed in 1991, to public in 1993,1995 R developers uses
GNU and R become Free
•GNU
• Lots of help available online
• similar to Matlab( not free) , but more user friendly.
•Excellent graphics capabilities
•built-in basic & advanced statistical and numerical analysis tools
Why R ?
WHAT IS R?
Installing R
•Installing R on Windows ,
•Installing R on Rstudio , more enjoyable.
working directory
getwd()
Data Types & Operators
## comments
Operators
x<-5
︡x
[1] 5
<- assignment operator
: sequence
x <- 1:5
x
[1] 1 2 3 4 5
#Please Make
#it readable
Logical
Y==6
X>Y
Data Types & Operators
Create Vector
Data Types
X<-c(1,2,2)
X<-c(1,2,NA,3)
is.na(X)Missing Values
?
x<-c(1:4) nummeric
X<-(TRUE,FALSE) logical
bad<-is.na(X)
X[!bad]
mean(X)
mean(X[!bad])
max(X)
max(X[!bad]) #var..
Data Types & Operators
Data Types
Create Matrix (all obj the same)
m <- matrix(nrow=2, ncol=3) #dim(m), attributes(m)
m[1][3] <- 6 #.....
M <-matrix( 1:6, nrow=2,ncol=3)
M
M<-matrix(c(4,5,6,7,8,9), nrow=2,ncol=3)
x<-matrix(c(2:16),nrow=3,ncol=5)
M%*%x ; M+M;M*M
subsiting a matrix , M[1,2]; M[1,];M[1,]
Data Types & Operators
#[[]] , vectors with singel [] but lists not.
L <- list(“a”,1,TRUE)
Subseting a list
[[1]], [1]
single [] returns a list, [[]] different data type.
Data Types
Create List ((different elements)
Data Types & Operators
> list1<-c(4,5,6)
> list2<-c(5,6,1,2,3)
> my_l<-list(list1,list2)
 my_l
 my_l[[3]]<-c(4,1)
 my_l[[length(my_l)+1]]<-c(4,1)
Data Types
Create List OF Lists
Data Types & Operators
Data Frame (tabulated data)
each column is a list (each col. same type)
> Df<-
data.frame(name=c("Amal","Basem","Cren"))
> Df<-cbind(Df,degree=c(6.4,3.5,4))
> Df
Df$name , use $ to retrieve object that has name.
Mean, degree ?
Data Types
Data Frame
Control Structure [Control the flow]
If else –-----------------
for – execute loop for fixed number of
times
while – execute while the condition of
while is true
…
d
Control Structure [Cont….]
If (x>3)
{y<-2 }
Else
{y<-0}
…
X<-
c(“a”,”b”,”c”,”d”)
For ( i in 1:4)
print(x[i])
If (x>3)
{ print (“Pass”)}
For(i in 1:10)
{print(i) }
Count<-0
# careful ..infinite
loops
While(count<10)
{count<-count+1
Print(count)
}}
IF FOR While
Writing a function
Ready! Your first function…
# in your script.
My_add<-function(x,y)
{ x+y}
# propmpet
My_add(6,4)
[take 2 number and add them together]
# what about * / ?
Example
?faithful
names(faithful)
hist(faithful$eruptions)
hist(faithful$eruptions,xlab="duration, min")
hist(faithful$eruptions,xlab="duration, min",main="Old faithful eruption")
hist(faithful$eruptions,xlab="duration, min",main="Old faithful
eruption",col=c("red","green","blue","yellow","pink","cyan","violet", "orange"))
Thanks…

Más contenido relacionado

La actualidad más candente

Introduction to R
Introduction to RIntroduction to R
Introduction to RAjay Ohri
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python PandasNeeru Mittal
 
R programming presentation
R programming presentationR programming presentation
R programming presentationAkshat Sharma
 
Introduction to R and R Studio
Introduction to R and R StudioIntroduction to R and R Studio
Introduction to R and R StudioRupak Roy
 
Introduction to data analysis using R
Introduction to data analysis using RIntroduction to data analysis using R
Introduction to data analysis using RVictoria López
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data scienceLong Nguyen
 
Data visualization using R
Data visualization using RData visualization using R
Data visualization using RUmmiya Mohammedi
 
Quantitative Data Analysis using R
Quantitative Data Analysis using RQuantitative Data Analysis using R
Quantitative Data Analysis using RTaddesse Kassahun
 
Introduction to Rstudio
Introduction to RstudioIntroduction to Rstudio
Introduction to RstudioOlga Scrivner
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesAndrew Ferlitsch
 
Introduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R StudioIntroduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R StudioAzmi Mohd Tamil
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotOlga Scrivner
 
Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubMartin Bago
 
8. R Graphics with R
8. R Graphics with R8. R Graphics with R
8. R Graphics with RFAO
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in REshwar Sai
 

La actualidad más candente (20)

Data Management in R
Data Management in RData Management in R
Data Management in R
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
R programming presentation
R programming presentationR programming presentation
R programming presentation
 
Introduction to R and R Studio
Introduction to R and R StudioIntroduction to R and R Studio
Introduction to R and R Studio
 
Introduction to data analysis using R
Introduction to data analysis using RIntroduction to data analysis using R
Introduction to data analysis using R
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
 
Data visualization using R
Data visualization using RData visualization using R
Data visualization using R
 
R programming
R programmingR programming
R programming
 
Quantitative Data Analysis using R
Quantitative Data Analysis using RQuantitative Data Analysis using R
Quantitative Data Analysis using R
 
Introduction to Rstudio
Introduction to RstudioIntroduction to Rstudio
Introduction to Rstudio
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
Introduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R StudioIntroduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R Studio
 
Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplot
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science Club
 
8. R Graphics with R
8. R Graphics with R8. R Graphics with R
8. R Graphics with R
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in R
 
R programming
R programmingR programming
R programming
 

Destacado

Applications in R - Success and Lessons Learned from the Marketplace
Applications in R - Success and Lessons Learned from the MarketplaceApplications in R - Success and Lessons Learned from the Marketplace
Applications in R - Success and Lessons Learned from the MarketplaceRevolution Analytics
 
Version Control With GitHub & RStudio
Version Control With GitHub & RStudioVersion Control With GitHub & RStudio
Version Control With GitHub & RStudioRsquared Academy
 
Step by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadStep by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadSamaa Hazem Hosny
 
R Programming: First Steps
R Programming: First StepsR Programming: First Steps
R Programming: First StepsRsquared Academy
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examplesDennis
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared Academy
 
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Revolution Analytics
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRsquared Academy
 

Destacado (16)

Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Chapter2
Chapter2Chapter2
Chapter2
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Applications in R - Success and Lessons Learned from the Marketplace
Applications in R - Success and Lessons Learned from the MarketplaceApplications in R - Success and Lessons Learned from the Marketplace
Applications in R - Success and Lessons Learned from the Marketplace
 
Revolution R: 100% R and more
Revolution R: 100% R and moreRevolution R: 100% R and more
Revolution R: 100% R and more
 
R program
R programR program
R program
 
Version Control With GitHub & RStudio
Version Control With GitHub & RStudioVersion Control With GitHub & RStudio
Version Control With GitHub & RStudio
 
Step by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadStep by Step Guidance to Study Abroad
Step by Step Guidance to Study Abroad
 
R Programming: First Steps
R Programming: First StepsR Programming: First Steps
R Programming: First Steps
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
Applications of R (DataWeek 2014)
Applications of R (DataWeek 2014)Applications of R (DataWeek 2014)
Applications of R (DataWeek 2014)
 
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
 

Similar a R programming Fundamentals

A short tutorial on r
A short tutorial on rA short tutorial on r
A short tutorial on rAshraf Uddin
 
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 AnalyticsArchana Gopinath
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSonaCharles2
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine LearningAmanBhalla14
 
How to obtain and install R.ppt
How to obtain and install R.pptHow to obtain and install R.ppt
How to obtain and install R.pptrajalakshmi5921
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data framekrishna singh
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAnshika865276
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Pa1 session 3_slides
Pa1 session 3_slidesPa1 session 3_slides
Pa1 session 3_slidesaiclub_slides
 

Similar a R programming Fundamentals (20)

A short tutorial on r
A short tutorial on rA short tutorial on r
A short tutorial on r
 
Data Types of R.pptx
Data Types of R.pptxData Types of R.pptx
Data Types of R.pptx
 
Unit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptxUnit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptx
 
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 language, an introduction
R language, an introductionR language, an introduction
R language, an introduction
 
R basics
R basicsR basics
R basics
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Programming in R
Programming in RProgramming in R
Programming in R
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
How to obtain and install R.ppt
How to obtain and install R.pptHow to obtain and install R.ppt
How to obtain and install R.ppt
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data frame
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.ppt
 
R language
R languageR language
R language
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Pa1 session 3_slides
Pa1 session 3_slidesPa1 session 3_slides
Pa1 session 3_slides
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 

Último

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.pdfDr Vijay Vishwakarma
 
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.pdfNirmal Dwivedi
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
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Ă...Nguyen Thanh Tu Collection
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
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).pptxEsquimalt MFRC
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Último (20)

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
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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Ă...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
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
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

R programming Fundamentals

  • 2. Objectives • How to program in R ? • Installing and sitting working directory? • Introduction , what is R? Data Types ,Operations on them • Formulating First Script . • Visualize data
  • 3. WHAT &WHY Ross Ihaka Robert Gentleman •R dialect From S •S is a statistical programming language •R developed in 1991, to public in 1993,1995 R developers uses GNU and R become Free •GNU • Lots of help available online • similar to Matlab( not free) , but more user friendly. •Excellent graphics capabilities •built-in basic & advanced statistical and numerical analysis tools Why R ? WHAT IS R?
  • 4. Installing R •Installing R on Windows , •Installing R on Rstudio , more enjoyable. working directory getwd()
  • 5. Data Types & Operators ## comments Operators x<-5 ︡x [1] 5 <- assignment operator : sequence x <- 1:5 x [1] 1 2 3 4 5 #Please Make #it readable Logical Y==6 X>Y
  • 6. Data Types & Operators Create Vector Data Types X<-c(1,2,2) X<-c(1,2,NA,3) is.na(X)Missing Values ? x<-c(1:4) nummeric X<-(TRUE,FALSE) logical bad<-is.na(X) X[!bad] mean(X) mean(X[!bad]) max(X) max(X[!bad]) #var..
  • 7. Data Types & Operators Data Types Create Matrix (all obj the same) m <- matrix(nrow=2, ncol=3) #dim(m), attributes(m) m[1][3] <- 6 #..... M <-matrix( 1:6, nrow=2,ncol=3) M M<-matrix(c(4,5,6,7,8,9), nrow=2,ncol=3) x<-matrix(c(2:16),nrow=3,ncol=5) M%*%x ; M+M;M*M subsiting a matrix , M[1,2]; M[1,];M[1,]
  • 8. Data Types & Operators #[[]] , vectors with singel [] but lists not. L <- list(“a”,1,TRUE) Subseting a list [[1]], [1] single [] returns a list, [[]] different data type. Data Types Create List ((different elements)
  • 9. Data Types & Operators > list1<-c(4,5,6) > list2<-c(5,6,1,2,3) > my_l<-list(list1,list2)  my_l  my_l[[3]]<-c(4,1)  my_l[[length(my_l)+1]]<-c(4,1) Data Types Create List OF Lists
  • 10. Data Types & Operators Data Frame (tabulated data) each column is a list (each col. same type) > Df<- data.frame(name=c("Amal","Basem","Cren")) > Df<-cbind(Df,degree=c(6.4,3.5,4)) > Df Df$name , use $ to retrieve object that has name. Mean, degree ? Data Types Data Frame
  • 11. Control Structure [Control the flow] If else –----------------- for – execute loop for fixed number of times while – execute while the condition of while is true … d
  • 12. Control Structure [Cont….] If (x>3) {y<-2 } Else {y<-0} … X<- c(“a”,”b”,”c”,”d”) For ( i in 1:4) print(x[i]) If (x>3) { print (“Pass”)} For(i in 1:10) {print(i) } Count<-0 # careful ..infinite loops While(count<10) {count<-count+1 Print(count) }} IF FOR While
  • 13. Writing a function Ready! Your first function… # in your script. My_add<-function(x,y) { x+y} # propmpet My_add(6,4) [take 2 number and add them together] # what about * / ?
  • 14. Example ?faithful names(faithful) hist(faithful$eruptions) hist(faithful$eruptions,xlab="duration, min") hist(faithful$eruptions,xlab="duration, min",main="Old faithful eruption") hist(faithful$eruptions,xlab="duration, min",main="Old faithful eruption",col=c("red","green","blue","yellow","pink","cyan","violet", "orange"))

Notas del editor

  1. S is a statistical programming language developed primarily by John Chambers and (in earlier versions) Rick Becker and Allan Wilks of Bell Laboratories. The aim of the language, as expressed by John Chambers, is "to turn ideas into software, quickly and faithfully.“ Bell Labs and formerly known as AT&T Bell Laboratories and Bell Telephone Laboratories) is the research and development subsidiary of Alcatel-Lucent. Bell Laboratories operates its headquarters in Murray Hill, New Jersey, United States, and has research and development facilities throughout the world. Researchers working at Bell Labs are credited with the development of radio astronomy, the transistor, the laser, the charge-coupled device (CCD), information theory, the UNIX operating system, the C programming language, S programming language and the C++ programming language. Eight Nobel Prizes have been awarded for work completed at Bell Laboratories. he R language is widely used among statisticians and data miners for developing statistical software[2][3] and data analysis.[3] Polls and surveys of data miners are showing R's popularity has increased substantially in recent year Packages The capabilities of R are extended through user-created packages, which allow specialized statistical techniques, graphical devices (ggplot2), import/export capabilities, reporting tools (knitr, Sweave), etc. These packages are developed primarily in R, and sometimes in Java, C and Fortran. A core set of packages is included with the installation of R, with more than 5,800 additional packages and 120,000 functions (as of June 2014) available at the Comprehensive R Archive Network (CRAN), Bioconductor, and other repositories. [6 The GNU Project i/ɡnuː/[3] is a free software, mass collaboration project, announced on 27 September 1983, by Richard Stallman at MIT. Its aim is to give computer users freedom and control in their use of their computers and computing devices, by collaboratively developing and providing software that is based on the following freedom rights: users are free to run the software, share it (copy, distribute), study it and modify it. GNU software guarantees these freedom-rights legally (via its license), and is therefore free software; the use of the word "free" always being taken to refer to freedom.
  2. R was first created by Ross Ihaka and Robert Gentleman at the University of Auckland in 1993 This is the directory/folder on your computer where you will store project files, data, and code. It's important that you tell R where the working directory is that you will be using so that it knows where to find the appropriate file (the working directory can be any directory on your computer). working directory getwd()
  3. Inf NAN
  4. Inf NAN
  5. Inf NAN
  6. Inf NAN
  7. Inf NAN
  8. Inf NAN
  9. Inf NAN
  10. Inf NAN
  11. Inf NAN
  12. Inf NAN