SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
INTRODUCTION TO R
Nimrod Priell, October 2012
Thursday, September 5, 13
WHAT IS R?
Thursday, September 5, 13
WHAT IS R?
What is C?
General-purpose programming language
How do you pick all pairs of researchers and managers in C?
Thursday, September 5, 13
WHAT IS R?
What is C?
General-purpose programming language
How do you pick all pairs of researchers and managers in C?
          char** researchers ... /* Lior, Nimrod, Gadi */
          char** managers ... /* Eran, Gadi, Roi */
          int i = 0
          int j = 0
          for (int i = 0; i < 3; i++) {
               for (int j = 0; j < 3; j++) {
                    if (strncmp(researchers[i], researchers[j], 30)) {
                         ... // expand our list, blah blah headache
Thursday, September 5, 13
WHAT IS R?
What is Python?
General purpose scripting language
How do you pick all pairs of researchers and managers in
Python?
Thursday, September 5, 13
WHAT IS R?
What is Python?
General purpose scripting language
How do you pick all pairs of researchers and managers in
Python?
[ (x, y) for x in [‘Gadi’,‘Nimrod’,‘Lior’] for y in [‘Gadi’, ‘Roi’, ‘Eran’] if x != y ]
Thursday, September 5, 13
WHAT IS R?
What is Python?
General purpose scripting language
How do you multiply matrices in Python?
Thursday, September 5, 13
WHAT IS R?
What is Python?
General purpose scripting language
How do you multiply matrices in Python?
def	
  matrixmult	
  (A,	
  B):
	
  	
  	
  	
  C	
  =	
  [[0	
  for	
  row	
  in	
  range(len(A))]	
  for	
  col	
  in	
  range(len(B[0]))]
	
  	
  	
  	
  for	
  i	
  in	
  range(len(A)):
	
  	
  	
  	
  	
  	
  	
  	
  for	
  j	
  in	
  range(len(B[0])):
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  for	
  k	
  in	
  range(len(B)):
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  C[i][j]	
  +=	
  A[i][k]*B[k][j]
	
  	
  	
  	
  return	
  C
Thursday, September 5, 13
WHAT IS R?
What is Python?
General purpose scripting language
How do you multiply matrices in Python?
import	
  numpy	
  as	
  np
x	
  =	
  np.arange(9).reshape((3,3))
y	
  =	
  np.arange(3)
print	
  np.dot(x,y)
x.T.dot(A.T).dot(A.inverse()).dot(x)
Thursday, September 5, 13
WHAT IS R?
What is Matlab?
Algebraic programming language
How do you multiply matrices in Matlab?
A = [ 1 2 3;
        4 5 6;
        7 8 9 ]
b = [ 6 4 -1 ]
A’ * b’ * b / A
Thursday, September 5, 13
WHAT IS R?
Incidentally, what is APL? (“A Programming Language”)
 life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}
(Conway's game of life in APL)
Thursday, September 5, 13
WHAT IS R?
Statistical programming language
Interpreted, Object Oriented, Functional
First-class data-sets, plotting and models.
cov(data$Income[data$Gender == ‘M’ & data$country %in%
c(‘uk’,’us’,’il’)], data$LifeExp[data$Gender == ‘F’ & data$Age
> 14])
lm(data, Income ~ Gender + Age)
predict(model, data)
Thursday, September 5, 13
WHY R?
Alternatives: Stata, SPSS, SAS, Excel
R is Free and Open Source
Packages for time-series, machine
learning, biological simulation,
computer vision, GPS, MapReduce,
animation, optimization, graph
analysis, reading any kind of data
format, weather prediction, ...
academia contributing
packages
http://cran.r-
project.org/web/
packages/
Thursday, September 5, 13
WHY R?
R has Reproducible Research
Excel: Click death
Demo #1
Thursday, September 5, 13
WHY R?
R is a general purpose programming language
Thursday, September 5, 13
WHY R?
R is a general purpose programming language
Thursday, September 5, 13
WHY R?
R is a general purpose programming language
Thursday, September 5, 13
WHY R?
R is a general purpose programming language
Other alternatives are
very specific: Weka,
Orange, etc.
Thursday, September 5, 13
R DEMO
The DataFrame
IO
Statistics & Models
Plotting
Remote RStudio
https://gist.github.com/2838511
Thursday, September 5, 13
WHY NOT R?
Terribly slow...
... But there’s RCPP, RHadoop and multicore
Terrible OO support and very quirky language
... But that only bothers you if you write packages
Thursday, September 5, 13

Contenu connexe

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

En vedette

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Introduction to R

  • 1. INTRODUCTION TO R Nimrod Priell, October 2012 Thursday, September 5, 13
  • 2. WHAT IS R? Thursday, September 5, 13
  • 3. WHAT IS R? What is C? General-purpose programming language How do you pick all pairs of researchers and managers in C? Thursday, September 5, 13
  • 4. WHAT IS R? What is C? General-purpose programming language How do you pick all pairs of researchers and managers in C?           char** researchers ... /* Lior, Nimrod, Gadi */           char** managers ... /* Eran, Gadi, Roi */           int i = 0           int j = 0           for (int i = 0; i < 3; i++) {                for (int j = 0; j < 3; j++) {                     if (strncmp(researchers[i], researchers[j], 30)) {                          ... // expand our list, blah blah headache Thursday, September 5, 13
  • 5. WHAT IS R? What is Python? General purpose scripting language How do you pick all pairs of researchers and managers in Python? Thursday, September 5, 13
  • 6. WHAT IS R? What is Python? General purpose scripting language How do you pick all pairs of researchers and managers in Python? [ (x, y) for x in [‘Gadi’,‘Nimrod’,‘Lior’] for y in [‘Gadi’, ‘Roi’, ‘Eran’] if x != y ] Thursday, September 5, 13
  • 7. WHAT IS R? What is Python? General purpose scripting language How do you multiply matrices in Python? Thursday, September 5, 13
  • 8. WHAT IS R? What is Python? General purpose scripting language How do you multiply matrices in Python? def  matrixmult  (A,  B):        C  =  [[0  for  row  in  range(len(A))]  for  col  in  range(len(B[0]))]        for  i  in  range(len(A)):                for  j  in  range(len(B[0])):                        for  k  in  range(len(B)):                                C[i][j]  +=  A[i][k]*B[k][j]        return  C Thursday, September 5, 13
  • 9. WHAT IS R? What is Python? General purpose scripting language How do you multiply matrices in Python? import  numpy  as  np x  =  np.arange(9).reshape((3,3)) y  =  np.arange(3) print  np.dot(x,y) x.T.dot(A.T).dot(A.inverse()).dot(x) Thursday, September 5, 13
  • 10. WHAT IS R? What is Matlab? Algebraic programming language How do you multiply matrices in Matlab? A = [ 1 2 3;         4 5 6;         7 8 9 ] b = [ 6 4 -1 ] A’ * b’ * b / A Thursday, September 5, 13
  • 11. WHAT IS R? Incidentally, what is APL? (“A Programming Language”)  life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵} (Conway's game of life in APL) Thursday, September 5, 13
  • 12. WHAT IS R? Statistical programming language Interpreted, Object Oriented, Functional First-class data-sets, plotting and models. cov(data$Income[data$Gender == ‘M’ & data$country %in% c(‘uk’,’us’,’il’)], data$LifeExp[data$Gender == ‘F’ & data$Age > 14]) lm(data, Income ~ Gender + Age) predict(model, data) Thursday, September 5, 13
  • 13. WHY R? Alternatives: Stata, SPSS, SAS, Excel R is Free and Open Source Packages for time-series, machine learning, biological simulation, computer vision, GPS, MapReduce, animation, optimization, graph analysis, reading any kind of data format, weather prediction, ... academia contributing packages http://cran.r- project.org/web/ packages/ Thursday, September 5, 13
  • 14. WHY R? R has Reproducible Research Excel: Click death Demo #1 Thursday, September 5, 13
  • 15. WHY R? R is a general purpose programming language Thursday, September 5, 13
  • 16. WHY R? R is a general purpose programming language Thursday, September 5, 13
  • 17. WHY R? R is a general purpose programming language Thursday, September 5, 13
  • 18. WHY R? R is a general purpose programming language Other alternatives are very specific: Weka, Orange, etc. Thursday, September 5, 13
  • 19. R DEMO The DataFrame IO Statistics & Models Plotting Remote RStudio https://gist.github.com/2838511 Thursday, September 5, 13
  • 20. WHY NOT R? Terribly slow... ... But there’s RCPP, RHadoop and multicore Terrible OO support and very quirky language ... But that only bothers you if you write packages Thursday, September 5, 13