Your SlideShare is downloading. ×
  • Like
Introduction to R
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Introduction to R

  • 187 views
Published

Background, provided with https://gist.github.com/Nimster/4757490 to explain R to programmers.

Background, provided with https://gist.github.com/Nimster/4757490 to explain R to programmers.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
187
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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