SlideShare uma empresa Scribd logo
1 de 22
Language R
By Franck Benault
Created 05/10/2015
Last update 22/12/2015
R introduction
● R is a statistical and graphical programming language
– Lingua Franca of Data Science
● Easy to use and powerful
● R is free and exists on very platform (Window, Unix)
– Large community
● There will be a lack of data-scientists
● Some elements are coming from Datacamp tutorials
R in public repositories of Github
Year Rank Nb public repository
2014 14th 48.574
2013 24th 7.867
2012 25th 5.626
● Index Tiobe
– http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
– R is 19th (September 2015)
R links
● Datacamp (R training)
– https://www.datacamp.com/
● Following datacamp, each year the number of R
users grows by 40 %.
● My examples in github
– https://github.com/franck-benault/test-R
R plan
● Environment
● Data types
– From basics to Dataframes
● R and statistics
● Diagrams
R environment
● Rstudio
R's fundamental data types
● Logical value (TRUE, FALSE, T, F, NA)
● Numeric (2, 4.5)
● Integer (2L)
● Character
● Complex
● Raw (store raw bytes)
● is.* functions (test : is.numeric(), is.integer() ...)
● as.* functions (conversion as.numeric(), as.integer() ...)
R datatype vector
● Vector
– Sequence of data elements (one dimension)
– Same datatype
– a <- c(1,2,5.3,6,-2,4)
– b <- c("one","two","three")
– d <- c(1,2.1,"three") # vector of character
● Methods
– is.vector(v)
– Length(v)
– Names(v) <- v2 #to associate a name to the values
● Basic data types are vectors
– a <-2
– is.vector(a) #return TRUE
R datatype vector, methods
● A lot of methods can be used on vector of numeric
– mean(V) #average
– median(V)
– sum(V)
● Name on vectors
– a <- c(1,6,5)
– n <- c("Ford","Renault", "Fiat")
– names(a) <- n
– b <- c(Ford=1, Renault=6, Fiat=5)
● You need a collection of elements with different datatype use a List
R datatype matrix, names
● Names with rownames, and colnames
– m <- matrix(1:6, byrow=TRUE, nrow=2)
– rownames(m) <- c("row1", "row2")
– colnames(m) <- c("col1", "col2", "col3")
● matrix(1:6, byrow=TRUE, nrow=2,
dimnames=list(c("row1", "row2"),c("col1","col2","col3")))
R datatype matrix
● Matrix
– two dimensions
– all elements have same type
● Creation, matrix() function with vector as parameter
– y<-matrix(1:20, nrow=5,ncol=4)
● Creation from two or more vectors, cbind or rbind
– cbind(1:4, 1:4, 1:4)
– rbind(1:4, 1:4, 1:4)
R datatype Factor
● Categorical variable
– Limited number of different values
– Belong to a category
● In R, Factor datastructure
● # example blood type
– blood <- c("A","B", "O", "AB","O", "A")
– blood_factor <- factor(blood)
– blood_factor
– #order of the levels alphabetical
– str(blood_factor)
– table(blood_factor)
R datatype List
● List
– One dimension
– Different R objects (even list, matrix, vector)
– Loss of functionality
● Creation of list
– song <- list("Rsome types", 190, 5)
● Naming a list
– names(song) <- c("title","duration","track")
– song <- list(title="Rsome types", duration=190, track=5)
R datatype dataframe
● Datasets
– Observations
– Variables
● Example people
– Row = observation
– Properties = variables
● Store that in R
– List
– Dataframe
R datatype dataframe
● data.frame
– Specifically for a dataset
– Rows = observations
– Columns = variables
– Contains elements of different types
● Read a csv file to create a dataframe
– people <-read.csv("./people.csv", sep="",
header=TRUE)
R and statistics
● Four types of variables (SS Stevens 1946)
– Nominal (categories)
– Ordinal (rank 1st 2nd etc)
– Interval (interval between each value is equal)
– Ratio (interval + « true » zero)
R and statistics : Data description
● Data description
– centrality
● Mean (average), function mean()
● Median (50%), function median()
● Mode (peak)
– Spread
● Standard deviation (variance and sd)
● Inter quartile range
– Scale() : transformation to Z-score (mean = 0)
R and statistics : main functions
● Rnorm()
– generation of a sample following the normal distribution
● Summary()
– Lot of information
● Min,max,average,median etc
Diagrams for qualitative data
● Qualitative, diagrams
– histogram
– Bar plot
– Pie chart
R Diagrams
● Qualitative, diagrams
– Bar plot
– Pie chart
● Quantitative
– Few numerical value
● Diagram = dot plot
– Lot of data
● Histogram
● Box plot
R Libraries
● Maps
– Install.packages(« maps »)
– library(« maps »)
– map(« world »)
– map(« france »)
– title("la France")
Conclusion
● When will you start using R ?
● Maybe it is also a good idea to follow a basis statistics
course

Mais conteúdo relacionado

Mais procurados

Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
Nimrita Koul
 

Mais procurados (20)

Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
R basics
R basicsR basics
R basics
 
R language
R languageR language
R language
 
R Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB AcademyR Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB Academy
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
R language
R languageR language
R language
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
R programming for data science
R programming for data scienceR programming for data science
R programming for data science
 
Programming in R
Programming in RProgramming in R
Programming in R
 
Introduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in RIntroduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in R
 
R programming language
R programming languageR programming language
R programming language
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
LSESU a Taste of R Language Workshop
LSESU a Taste of R Language WorkshopLSESU a Taste of R Language Workshop
LSESU a Taste of R Language Workshop
 
Introduction to data analysis using R
Introduction to data analysis using RIntroduction to data analysis using R
Introduction to data analysis using R
 
R programming Language , Rahul Singh
R programming Language , Rahul SinghR programming Language , Rahul Singh
R programming Language , Rahul Singh
 
A short tutorial on r
A short tutorial on rA short tutorial on r
A short tutorial on r
 
Functional Programming in R
Functional Programming in RFunctional Programming in R
Functional Programming in R
 
R language tutorial
R language tutorialR language tutorial
R language tutorial
 

Destaque

หน่วยที่ 1 ระบบความปลอดภัยไชยา
หน่วยที่ 1 ระบบความปลอดภัยไชยาหน่วยที่ 1 ระบบความปลอดภัยไชยา
หน่วยที่ 1 ระบบความปลอดภัยไชยา
Sayun Chai
 

Destaque (20)

8.3.1formula
8.3.1formula8.3.1formula
8.3.1formula
 
Shahnawaz_resume
Shahnawaz_resumeShahnawaz_resume
Shahnawaz_resume
 
05. cuestionario de éxodo 11 epílogo al corazón duro
05.  cuestionario de éxodo 11 epílogo al corazón duro05.  cuestionario de éxodo 11 epílogo al corazón duro
05. cuestionario de éxodo 11 epílogo al corazón duro
 
Presentación docentes idear
Presentación docentes idearPresentación docentes idear
Presentación docentes idear
 
Monarchs (France, Austria)
Monarchs (France, Austria)Monarchs (France, Austria)
Monarchs (France, Austria)
 
kamal_CV
kamal_CVkamal_CV
kamal_CV
 
چگونه پولدار شوم
چگونه پولدار شومچگونه پولدار شوم
چگونه پولدار شوم
 
ใบความรู้ พุทธประวัติ-ตรัสรู้ ป.4+465+dltvsocp4+54soc p04 f04-4page
ใบความรู้  พุทธประวัติ-ตรัสรู้ ป.4+465+dltvsocp4+54soc p04 f04-4pageใบความรู้  พุทธประวัติ-ตรัสรู้ ป.4+465+dltvsocp4+54soc p04 f04-4page
ใบความรู้ พุทธประวัติ-ตรัสรู้ ป.4+465+dltvsocp4+54soc p04 f04-4page
 
Managing Content and Reputation on the Web
Managing Content and Reputation on the WebManaging Content and Reputation on the Web
Managing Content and Reputation on the Web
 
หน่วยที่ 1 ระบบความปลอดภัยไชยา
หน่วยที่ 1 ระบบความปลอดภัยไชยาหน่วยที่ 1 ระบบความปลอดภัยไชยา
หน่วยที่ 1 ระบบความปลอดภัยไชยา
 
Organizational theory behaviour by Vinato Awomi
Organizational theory behaviour by Vinato AwomiOrganizational theory behaviour by Vinato Awomi
Organizational theory behaviour by Vinato Awomi
 
The dark Ages Part 2
The dark Ages Part 2The dark Ages Part 2
The dark Ages Part 2
 
Presentación docentes
Presentación docentesPresentación docentes
Presentación docentes
 
Enfoques para el estudio de la opinión pública
Enfoques para el estudio de la opinión públicaEnfoques para el estudio de la opinión pública
Enfoques para el estudio de la opinión pública
 
Advanced R cheat sheet
Advanced R cheat sheetAdvanced R cheat sheet
Advanced R cheat sheet
 
Learning R and Teaching R
Learning R and Teaching RLearning R and Teaching R
Learning R and Teaching R
 
R Markdown Tutorial For Beginners
R Markdown Tutorial For BeginnersR Markdown Tutorial For Beginners
R Markdown Tutorial For Beginners
 
Prueba piloto #2 techo verde sobre cubierta metálica inclinada
Prueba piloto #2 techo verde sobre cubierta metálica inclinadaPrueba piloto #2 techo verde sobre cubierta metálica inclinada
Prueba piloto #2 techo verde sobre cubierta metálica inclinada
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
 
56. salmo 57 diagníostico de mi corzón
56.  salmo 57 diagníostico de mi corzón56.  salmo 57 diagníostico de mi corzón
56. salmo 57 diagníostico de mi corzón
 

Semelhante a Introduction to the language R

Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
helzerpatrina
 
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
SonaCharles2
 

Semelhante a Introduction to the language R (20)

Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
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
 
Unit1_Introduction to R.pdf
Unit1_Introduction to R.pdfUnit1_Introduction to R.pdf
Unit1_Introduction to R.pdf
 
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
 
Rattle Graphical Interface for R Language
Rattle Graphical Interface for R LanguageRattle Graphical Interface for R Language
Rattle Graphical Interface for R Language
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL Server
 
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
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
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
 
Lecture_R.ppt
Lecture_R.pptLecture_R.ppt
Lecture_R.ppt
 
An R primer for SQL folks
An R primer for SQL folksAn R primer for SQL folks
An R primer for SQL folks
 
Introduction to Data Analtics with Pandas [PyCon Cz]
Introduction to Data Analtics with Pandas [PyCon Cz]Introduction to Data Analtics with Pandas [PyCon Cz]
Introduction to Data Analtics with Pandas [PyCon Cz]
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdf
 
Introduction to R.pptx
Introduction to R.pptxIntroduction to R.pptx
Introduction to R.pptx
 
Introduction to basic statistics
Introduction to basic statisticsIntroduction to basic statistics
Introduction to basic statistics
 

Mais de fbenault (13)

Bdd java
Bdd javaBdd java
Bdd java
 
Property based-testing
Property based-testingProperty based-testing
Property based-testing
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Test ng
Test ngTest ng
Test ng
 
Assertj-DB
Assertj-DBAssertj-DB
Assertj-DB
 
Assertj-core
Assertj-coreAssertj-core
Assertj-core
 
Junit
JunitJunit
Junit
 
System rules
System rulesSystem rules
System rules
 
Db in-memory
Db in-memoryDb in-memory
Db in-memory
 
DbSetup
DbSetupDbSetup
DbSetup
 
Guava
GuavaGuava
Guava
 
Java8
Java8Java8
Java8
 
Easymock
EasymockEasymock
Easymock
 

Último

Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 

Introduction to the language R

  • 1. Language R By Franck Benault Created 05/10/2015 Last update 22/12/2015
  • 2. R introduction ● R is a statistical and graphical programming language – Lingua Franca of Data Science ● Easy to use and powerful ● R is free and exists on very platform (Window, Unix) – Large community ● There will be a lack of data-scientists ● Some elements are coming from Datacamp tutorials
  • 3. R in public repositories of Github Year Rank Nb public repository 2014 14th 48.574 2013 24th 7.867 2012 25th 5.626 ● Index Tiobe – http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html – R is 19th (September 2015)
  • 4. R links ● Datacamp (R training) – https://www.datacamp.com/ ● Following datacamp, each year the number of R users grows by 40 %. ● My examples in github – https://github.com/franck-benault/test-R
  • 5. R plan ● Environment ● Data types – From basics to Dataframes ● R and statistics ● Diagrams
  • 7. R's fundamental data types ● Logical value (TRUE, FALSE, T, F, NA) ● Numeric (2, 4.5) ● Integer (2L) ● Character ● Complex ● Raw (store raw bytes) ● is.* functions (test : is.numeric(), is.integer() ...) ● as.* functions (conversion as.numeric(), as.integer() ...)
  • 8. R datatype vector ● Vector – Sequence of data elements (one dimension) – Same datatype – a <- c(1,2,5.3,6,-2,4) – b <- c("one","two","three") – d <- c(1,2.1,"three") # vector of character ● Methods – is.vector(v) – Length(v) – Names(v) <- v2 #to associate a name to the values ● Basic data types are vectors – a <-2 – is.vector(a) #return TRUE
  • 9. R datatype vector, methods ● A lot of methods can be used on vector of numeric – mean(V) #average – median(V) – sum(V) ● Name on vectors – a <- c(1,6,5) – n <- c("Ford","Renault", "Fiat") – names(a) <- n – b <- c(Ford=1, Renault=6, Fiat=5) ● You need a collection of elements with different datatype use a List
  • 10. R datatype matrix, names ● Names with rownames, and colnames – m <- matrix(1:6, byrow=TRUE, nrow=2) – rownames(m) <- c("row1", "row2") – colnames(m) <- c("col1", "col2", "col3") ● matrix(1:6, byrow=TRUE, nrow=2, dimnames=list(c("row1", "row2"),c("col1","col2","col3")))
  • 11. R datatype matrix ● Matrix – two dimensions – all elements have same type ● Creation, matrix() function with vector as parameter – y<-matrix(1:20, nrow=5,ncol=4) ● Creation from two or more vectors, cbind or rbind – cbind(1:4, 1:4, 1:4) – rbind(1:4, 1:4, 1:4)
  • 12. R datatype Factor ● Categorical variable – Limited number of different values – Belong to a category ● In R, Factor datastructure ● # example blood type – blood <- c("A","B", "O", "AB","O", "A") – blood_factor <- factor(blood) – blood_factor – #order of the levels alphabetical – str(blood_factor) – table(blood_factor)
  • 13. R datatype List ● List – One dimension – Different R objects (even list, matrix, vector) – Loss of functionality ● Creation of list – song <- list("Rsome types", 190, 5) ● Naming a list – names(song) <- c("title","duration","track") – song <- list(title="Rsome types", duration=190, track=5)
  • 14. R datatype dataframe ● Datasets – Observations – Variables ● Example people – Row = observation – Properties = variables ● Store that in R – List – Dataframe
  • 15. R datatype dataframe ● data.frame – Specifically for a dataset – Rows = observations – Columns = variables – Contains elements of different types ● Read a csv file to create a dataframe – people <-read.csv("./people.csv", sep="", header=TRUE)
  • 16. R and statistics ● Four types of variables (SS Stevens 1946) – Nominal (categories) – Ordinal (rank 1st 2nd etc) – Interval (interval between each value is equal) – Ratio (interval + « true » zero)
  • 17. R and statistics : Data description ● Data description – centrality ● Mean (average), function mean() ● Median (50%), function median() ● Mode (peak) – Spread ● Standard deviation (variance and sd) ● Inter quartile range – Scale() : transformation to Z-score (mean = 0)
  • 18. R and statistics : main functions ● Rnorm() – generation of a sample following the normal distribution ● Summary() – Lot of information ● Min,max,average,median etc
  • 19. Diagrams for qualitative data ● Qualitative, diagrams – histogram – Bar plot – Pie chart
  • 20. R Diagrams ● Qualitative, diagrams – Bar plot – Pie chart ● Quantitative – Few numerical value ● Diagram = dot plot – Lot of data ● Histogram ● Box plot
  • 21. R Libraries ● Maps – Install.packages(« maps ») – library(« maps ») – map(« world ») – map(« france ») – title("la France")
  • 22. Conclusion ● When will you start using R ? ● Maybe it is also a good idea to follow a basis statistics course