150 likes | 296 Views
R. Roger Barlow HEP Computing seminar 21 st February 2008. What is R?. A data handling+graphics system with particular emphasis on statistical tools Compare and contrast: PAW, Root, Easyplot, Matlab…. Getting hold of R. Google ‘R download’ and follow instructions Quite painless
E N D
R Roger Barlow HEP Computing seminar 21st February 2008
What is R? A data handling+graphics system with particular emphasis on statistical tools Compare and contrast: PAW, Root, Easyplot, Matlab…
Getting hold of R Google ‘R download’ and follow instructions Quite painless Windows and unix versions exist
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.
What do you get? Help button Gives help And manuals Command line for entering instructions Screen where plots appear
Assignment and vectors c means ‘concatenate’ Assignment operators
Arguments Type help (“<whatever>”) Eg help(“rnorm”)
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) }
Files and stuff For hardcopy: >postscript(“<filename>”) >… plotting >dev.off() Also png(“<filename>”) and others File input >s=read.table(“<filename>") >print(s$V1) >plot(s$V1,s$V2) etc Or read.table(“<filename>”,HEADER=TRUE) And first line of file will be taken as names used instead of V1, V2…
Interested? • Type demo() at the prompt