introduction to r bddsil meetup

Post on 13-Jul-2015

353 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

INTRODUCTION TO RNimrod Priell, October 2012

Monday, February 11, 13

WHAT IS R?

Monday, February 11, 13

WHAT IS R?

What is C?

General-purpose programming language

How do you pick all pairs of researchers and managers in C?

Monday, February 11, 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

Monday, February 11, 13

WHAT IS R?

What is Python?

General purpose scripting language

How do you pick all pairs of researchers and managers in Python?

Monday, February 11, 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 ]

Monday, February 11, 13

WHAT IS R?

What is Python?

General purpose scripting language

How do you multiply matrices in Python?

Monday, February 11, 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

Monday, February 11, 13

WHAT IS R?

What is Python?

General purpose scripting language

How do you multiply matrices in Python?import  numpy  as  npx  =  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)

Monday, February 11, 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

Monday, February 11, 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)

Monday, February 11, 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)

Monday, February 11, 13

WHY R?

Alternatives: Stata, SPSS, SAS, Excel

R is Free and Open Source

Packages for time-series, machinelearning, biological simulation,computer vision, GPS, MapReduce,animation, optimization, graphanalysis, reading any kind of dataformat, weather prediction, ...

academia contributing packages

http://cran.r-project.org/web/packages/

Monday, February 11, 13

WHY R?

R has Reproducible Research

Excel: Click death

Demo #1

Monday, February 11, 13

WHY R?

R is a general purpose programming language

Monday, February 11, 13

WHY R?

R is a general purpose programming language

Monday, February 11, 13

WHY R?

R is a general purpose programming language

Monday, February 11, 13

WHY R?

R is a general purpose programming language

Other alternatives are very specific: Weka, Orange, etc.

Monday, February 11, 13

R DEMO

The DataFrame

IO

Statistics & Models

Plotting

Remote RStudio

https://gist.github.com/2838511

Monday, February 11, 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

Monday, February 11, 13

Thanks!

Nimrod Priell nimrod.priell@gmail.com@nimrodpriellwww.educated-guess.com

Monday, February 11, 13

SOME SOURCES

Tal Galili’s Blog Archivehttp://www.r-bloggers.com/

Israeli R User Grouphttp://groups.google.com/group/israel-r-user-group

RSeek Search Enginehttp://www.rseek.org/

R Mailing List Archiveshttp://tolstoy.newcastle.edu.au/R/

Monday, February 11, 13

top related