我正在尝试通过 facet 学习 ggplot。以下是在 Rstudio 中可用的代码:
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
# With one variable
p + facet_grid(. ~ cyl)
然而,在我添加了ncol=2之后,它显示了错误:
p + facet_grid( ~ cyl,ncol=2)
Error in facet_grid(~cyl, ncol = 2) : unused argument (ncol = 2)