data(cars)
dim(cars)
names(cars)
summary(cars)
plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)",las = 1, xlim = c(0, 25))
install.packages("nutshell")
library(nutshell)
data(field.goals)
head(field.goals)
hist(field.goals$yards)
hist(field.goals$yards, breaks=35)
table(field.goals$play.type)
stripchart(field.goals[field.goals$play.type=="FG blocked",]$yards,pch=19, method="jitter")
#method参数设置成jitter可避免重叠而使每个点都能清楚地显示
data(consumption)
head(consumption)
library(lattice)
dotplot(Amount~Year|Food, consumption)
dotplot(Amount ~ Year | Food,data=consumption, aspect="xy",scales=list(relation="sliced", cex=.4))
vignette("grid") #查看指南文档
example(glm) #运行相关例子
vignette(all=F)#查看已加载的所有包的指南文档
getOption("defaultPackages")
(.packages())#查看当前已加载包的列表
(.packages(all.available=TRUE))#查看所有可用包
library()
install.packages(c("tree","maptree")) #安装包到默认位置
remove.packages(c("tree", "maptree"),.Library) #从库中删除包
package.skeleton(name="nutshell",path="~/Documents/book/current/")#创建一个包目录