【发布时间】:2015-03-25 16:27:04
【问题描述】:
您好:我正在为我正在教授的一门课程使用“提示”数据集。我想生成一个 .png 文件,该文件在绘图设备的顶行(理想情况下在窗口的中心顶部)具有小费作为大小的函数,底行是条件图提示作为大小的函数,由从数据集中包含的 total_bill 变量重新编码的分类变量分组。我对 ggplot2 环境更加熟悉,尽管我也不太清楚如何在那里执行此操作。 谢谢!
library(reshape2)
library(grid)
library(lattice)
data(tips)
tips$bill2<-cut(tips$total_bill, breaks=3, labels=c('low', 'medium', 'high'))
#Create one plot window with this plot on the top row, ideally in the center
xyplot(tip~size, data=tips,type=c('r', 'p'))
#With this plot in the second row
xyplot(tip~size|bill2, data=tips, type=c('r', 'p'))
【问题讨论】: