SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Dernier

Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
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
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 

Dernier (20)

Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
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 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...
 
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
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
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 Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 

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