Документ взят из кэша поисковой машины. Адрес оригинального документа : http://herba.msu.ru/shipunov/school/biol_240/2014_2015/20150218.r
Дата изменения: Wed Feb 18 22:15:50 2015
Дата индексирования: Sun Apr 10 19:10:06 2016
Кодировка:
getwd()

i <- read.table("http://ashipunov.info/data/islets.txt", h=T, sep="\t")
str(i)
square <- i$width * i$length * .6 * .6
scatter.smooth(log10(square), i$species)
identify(log10(square), i$species)

height <- trees[,2]
cut(height,3)
cut(height,3, labels=1:3)
cut(height,3, labels=c("a","b","c"))
cut(height,3, labels=c("a","b","c"), ordered=T)
cut(height,5, labels=c("F","D","C","B","A"), ordered=T)
cut(height,5, ordered=T)

TRUE
FALSE
T
F
T + F
T * F

height
height < 72
sum(height < 72)
height >= 75
sum(height >= 75)
height == 75
presence <- c(F, T, T, F, F)
presence
presence * 1

sex <- c("male","female","male","male","female","male","male")
is.numeric(sex)
is.character(sex)
sex
str(sex)
str(presence)
table(sex)
table(presence)

factor(sex)
plot(sex) # wrong!
plot(factor(sex))

cut(height,3, labels=c("a","b","c"), ordered=T)
plot(cut(height,3, labels=c("a","b","c"), ordered=T))
sex.f <- factor(sex)
is.factor(sex.f)
is.character(sex.f)
str(sex.f)
levels(sex.f)

as.numeric(sex)
as.numeric(sex.f)

w <- c(69, 68, 93, 87, 59, 82, 72)
x <- c(174, 162, 188, 192, 165, 168, 172)
plot(x, w)
plot(x, w, pch=as.numeric(sex.f), col=as.numeric(sex.f))
plot(x, w, pch=as.numeric(sex.f), col=as.numeric(sex.f))
legend("topleft", pch=1:2, col=1:2, legend=levels(sex.f))

m <- c("L","S","XL","XXL","S","M","L")
m.f <- factor(m)
levels(m.f)
m.o <- ordered(m.f, levels=c("S","M","L","XL","XXL"))
levels(m.o)
m.o

a <- factor(3:5)
a
as.number(a)
as.numeric(a)
as.numeric(as.character(a))

pi
letters
LETTERS
exp(1)