September 2013
Beginner to intermediate
396 pages
8h 8m
English
sd function:
sd(0:100)
demo(plotmath) and hit Enter, or click the plots to see what’s on offer.
Simple division gets the reciprocal, and atan calculates the inverse (arc) tangent:
atan(1/1:1000)
Assign variables using <-:
x<-1:1000y<-atan(1/x)z<-1/tan(y)
all.equal is usually what you need:
x==z identical(x,z)all.equal(x,z)all.equal(x,z,tolerance=0)
true_and_missing<-c(NA,TRUE,NA)false_and_missing<-c(FALSE,FALSE,NA)mixed<-c(TRUE,FALSE,NA)any(true_and_missing)any(false_and_missing)any(mixed)all(true_and_missing)all(false_and_missing)all(mixed)
class(Inf)class(NA)class(NaN)class("")
Repeat with typeof, mode, and storage.mode.
pets<-factor(sample(c("dog","cat","hamster","goldfish"),1000,replace=TRUE))head(pets)summary(pets)
Converting to factors is recommended but not compulsory.
carrot<-1potato<-2swede<-3ls(pattern="a")
Your vegetables may vary.
seq_len and seq_along:
n <- ...