《R in action》《R语言实战》源代码_1
程序员文章站
2022-06-21 10:43:59
...
1-1 一个R语言会话示例
age <- c(1, 3, 5, 2, 11, 9, 3, 9, 12, 3)
weight <- c(4.4, 5.3, 7.2, 5.2, 8.5, 7.3, 6, 10.4,
10.2, 6.1)
mean(weight)
sd(weight)
cor(age, weight)
plot(age, weight)
# q()
1-2 用于管理R工作空间的命令示例
setwd("C:/myprojects/project1")
options()
options(digits=3)
x <- runif(20)
summary(x)
hist(x)
savehistory()
save.image()
# q()
1-3 使用一个新的包
help.start()
install.packages("vcd")
help(package = "vcd")
library(vcd)
help(Arthritis)
Arthritis
example(Arthritis)
# q()