我有以下代码:
plotfn= function(u) {
flt = filter(d, utensil ==u)
ggplot(flt,aes(x=p)) + geom_histogram(binwidth = 0.5, position= position_dodge(0.5), color="black",fill="cadetblue4")+ ggtitle("Histogram of P")+labs( x="P", y="Number of Observations")
}
lapply(unique(d$utensil),plotfn)
Run Code Online (Sandbox Code Playgroud)
我试图做一个par(mfrow= c(3,3))在一个屏幕上获得所有9个情节,但这是行不通的。我必须使用ggplot。