Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why ncol option does not work in my facet_grid in R [duplicate]

Tags:

r

facet

r-grid

I am trying to learn ggplot with facet. here is the codes works in Rstudio

p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()

  # With one variable
p + facet_grid(. ~ cyl)

however, it shows error for ncol after I added ncol=2 :

    p + facet_grid( ~ cyl,ncol=2)

Error in facet_grid(~cyl, ncol = 2) : unused argument (ncol = 2)
like image 389
czqiu Avatar asked Mar 06 '15 21:03

czqiu


Video Answer


1 Answers

#use facet_wrap
p + facet_wrap( ~ cyl, ncol = 2)
like image 190
Metrics Avatar answered Sep 18 '22 20:09

Metrics