我的数据集是一个data.frame NewAuto,它的名字是:
[1] "mpg" "cylinders" "displacement" "horsepower" "weight"
[6] "acceleration" "year" "origin" "name" "MPG01"
我想用 ggplot 在一张图片上绘制七个图。它是更大代码的一部分。我的目标是制作与其他列类似的情节 mpg。每个图都应标有 y 轴。
SCATTERplots <- lapply(
2:8,
function( column ){
DataPlot <- ggplot(
data = NewAuto,
aes(
x = mpg,
y=NewAuto[,column]
)
)+geom_point()+facet_grid(.~MPG01)+ylab(names(NewAuto)[column])
return( DataPlot)
}
)
do.call( grid.arrange, SCATTERplots)
不幸的是我得到:
Error in `[.data.frame`(NewAuto, , column) : object 'column' not found
我怎样才能解决这个问题?
我是初学者,所以请考虑到这一点。