私のデータセットは data.frame NewAuto で、名前は次のとおりです。
[1] "mpg" "cylinders" "displacement" "horsepower" "weight"
[6] "acceleration" "year" "origin" "name" "MPG01"
ggplot で 1 つの画像に 7 つのプロットを作成したいと考えています。それはより大きなコードの一部です。私の目的は、同様のプロット 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
どうすればこれを修正できますか?
初心者ですので、ご了承ください。