Presentation is loading. Please wait.

Presentation is loading. Please wait.

R Roger Barlow HEP Computing seminar 21 st February 2008.

Similar presentations


Presentation on theme: "R Roger Barlow HEP Computing seminar 21 st February 2008."— Presentation transcript:

1 R Roger Barlow HEP Computing seminar 21 st February 2008

2 Roger Barlow: R Slide 2 What is R? A data handling+graphics system with particular emphasis on statistical tools Compare and contrast: PAW, Root, Easyplot, Matlab…

3 Roger Barlow: R Slide 3 Getting hold of R Google ‘R download’ and follow instructions Quite painless Windows and unix versions exist

4 Roger Barlow: R Slide 4 Philosophy 1.1 The R environment R is an integrated suite of software facilities for data manipulation, calculation and graphical display. Among other things it has an effective data handling and storage facility, a suite of operators for calculations on arrays, in particular matrices, a large, coherent, integrated collection of intermediate tools for data analysis, graphical facilities for data analysis and display either directly at the computer or on hardcopy, and a well developed, simple and effective programming language (called ‘S’) which includes conditionals, loops, user defined recursive functions and input and output facilities. (Indeed most of the system supplied functions are themselves written in the S language.) The term “environment” is intended to characterize it as a fully planned and coherent system, rather than an incremental accretion of very specific and inflexible tools, as is frequently the case with other data analysis software.

5 Roger Barlow: R Slide 5 What do you get? Command line for entering instructions Help button Gives help And manuals Screen where plots appear

6 Roger Barlow: R Slide 6 Example: simple stuff

7 Roger Barlow: R Slide 7 Assignment and vectors c means ‘concatenate’ Assignment operators

8 Roger Barlow: R Slide 8 Plotting

9 Roger Barlow: R Slide 9 Arguments Type help (“ ”) Eg help(“rnorm”)

10 Roger Barlow: R Slide 10 More plotting

11 Roger Barlow: R Slide 11 Other plots

12 Roger Barlow: R Slide 12 Functions and scripts

13 Roger Barlow: R Slide 13 What was in the source file print("Loading Fourier routines") PIBY2<-asin(1); PI<-2*piby2; TWOPI=2*PI; ROOT2PI=sqrt(TWOPI) alternation<-function(n) {2*(seq(1:n) % 2)- 1} fourier<-function(data,lo,hi) { nbins <- length(data) nn=round(nbins/2) W <- hi-lo delta <- W /nbins ii<-seq(1,nbins)-1 x<-delta*ii+lo theta<-x*twopi/W fc<-seq(1,nn) fs<-seq(1,nn) for(i in seq(1,nn)){ fc[i]<- sum(cos(i*theta)*data) fs[i]<- sum(sin(i*theta)*data) } fc[nn]=fc[nn]/2 fs[nn]=0 list(c=2*fc/nbins,s=2*fs/nbins, zero=sum(data)/nbins) }

14 Roger Barlow: R Slide 14 Files and stuff For hardcopy: >postscript(“ ”) >… plotting >dev.off() Also png(“ ”) and others File input >s=read.table(“ ") >print(s$V1) >plot(s$V1,s$V2) etc Or read.table(“ ”,HEADER=TRUE) And first line of file will be taken as names used instead of V1, V2…

15 Roger Barlow: R Slide 15 Interested? Type demo() at the prompt


Download ppt "R Roger Barlow HEP Computing seminar 21 st February 2008."

Similar presentations


Ads by Google