其典型使用方法如下;graph_type(formula, data=) 这里的graph_type是指待绘制的图表类型,如下表所示: 图形类型 描述 公式 barchart 条形图 x~A or A~x bwplot # 按因子gear和cyl的不同组合绘制箱线图 bwplot(cyl.f~mpg|gear.f, ylab="Cylinders", xlab="Miles perGallon", main
安装和加载包: install.packages("lattice") library(lattice) 基本用法: # 使用上述 df 数据框 bwplot(Value ~ Group, data = df, main = "分组箱线图", xlab = "组别", ylab = "数值") bwplot 是 lattice 包中用于绘制箱线图的函数。 t.test") # 检验的类型,可以更改 p1 结果如下: 方式三:使用 lattice 包 # lattice library(lattice) # 使用上述 df 数据框 head(df) bwplot
> bwplot(cyl~mpg|gear, main="box plots by cylinders and gears", xlab="car weight",ylab="cylinders") ?
levelplot() z ~ y*x 三维散点图 cloud() z ~ x*y|A 三维线框图 wireframe() z ~ y*x 条形图 barchart() x ~ A或A ~ x 箱线图 bwplot
and whisker plots to compare models scales <- list(x=list(relation="free"), y=list(relation="free")) bwplot
每个变量的列名后附加插补编号(如Ozone.1,Ozone.2),且列顺序与原始数据一致;而"repeated"同样是横向展开,但列按插补编号分组排列(即先列出所有第1次插补的变量,再是第2次的,依此类推)# 诊断图绘制bwplot
0.9705882 0.9836601 0.9901639 0.9885492 0.9934641 1.0000000 0 dotplot(cv.values, metric = "ROC") bwplot
这时候我们在使用lattice包绘制箱线图,看看在颜色上的分布是否有区别 library(lattice) bwplot(depth~color,data=trai_date) ?
A) xyplot() B) stripplot() C) barchart() D) bwplot() 答案:(B) 上文所绘是条型图而选项A、C、D会分别产生散点图、柱状图以及箱线图。
plot(f,y)——箱线图,f是因子,y是与f因子对应的数值 bwplot(<factor> ~ <y>,data,ylab)——lattice包的箱图,绘制不同factor下的y的箱图 (条件绘图,在某个因子取值集合下的y值变化) bwplot(size~a1,data,panel=panel.bpplot,prob=seq(.01,.49,by=.01),datadensity