Intro With R
Intro With R
Data Team
Types of statistical software
command-line software
◦ requires knowledge of syntax of commands
◦ reproducible results through scripts
◦ detailed analyses possible
GUI-based software
◦ does not require knowledge of commands
◦ not reproducible actions
INTRODUCTION TO R 3
Well-known statistical software
SAS
SPSS
Minitab
Statgraphics
S-Plus
R
…
INTRODUCTION TO R 4
R
free
maintained by top quality experts
available on all platforms
continuous improvement
Available through www.r-project.org
5
Basic operations
assignment operation: a <- 2+sqrt(5)
help function:
◦ help(pnorm)
◦ help.search(“normal distribution”)
probability functions:
◦ d (density): dgamma(x,n,θ)
◦ p (probability=cdf): pweibull(x,3,2)
◦ q (quantile): qnorm(0.95)
◦ r (random numbers): rexp(10,θ)
INTRODUCTION TO R 6
Data creation + I/O
create
◦ vectors: c(1,2,3)
◦ matrices: matrix(c(1,2,3,4,5,6),2,3,byrow=T) (2=#rows)
◦ list
patterns:
◦ “:” (1,2,3) = 1:3
◦ seq (1,2,3) = seq(1,3,by=1)
read data
INTRODUCTION TO R 7
Basic statistics
summary
mean
stdev
t.test
boxplot
INTRODUCTION TO R 8
Packages
specialized functions available through packages and libraries
in Windows interface choose Packages -> Load Packages
examples of packages:
◦ qcc (quality control)
◦ survival
INTRODUCTION TO R 9
Functions
Analyses that have to be performed often can be put in the form of functions
Example: simple <- function(data,mean=0,alpha=0.05)
{hist(data),t.test(data,conf.level=alpha,mu=mean,alternative=“two-sided”)}
simple(data,4) uses the default value 0.05 and test the null hypothesis mu=4.
INTRODUCTION TO R 10
Useful web sites
www.r-project.org
http://cran.r-project.org/doc/contrib/Short-refcard.pdf
http://www.uni-muenster.de/ZIV/Mitarbeiter/BennoSueselbeck/s-html/
shelp.html
http://www.maths.lth.se/help/R/
http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/R-intro.html
http://stats.math.uni-augsburg.de/JGR/
http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/index.html
INTRODUCTION TO R 11