Introduction 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
hybrid types (both command-line and GUI)
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 [Link]
5
Basic operations
assignment operation: a <- 2+sqrt(5)
help function:
◦ help(pnorm)
◦ [Link](“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)
working directories and files:
◦ setwd
◦ getwd
◦ attach
read data
INTRODUCTION TO R 7
Basic statistics
summary
mean
stdev
[Link]
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),[Link](data,[Link]=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
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
INTRODUCTION TO R 11