Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R help - Error: `rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list [closed]

Tags:

r

ggplot2

I'd like help understanding the following error when using ggplot2 facet_wrap

Error: `rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list

I'm using fresh installs on a new computer. And am now getting the error on any data frames I try to plot. For example

test.csv

party,status,emissions
Australia,low,20
Australia,mid,30
Australia,high,40
Finland,low,60
Finland,mid,10
Australia,high,45

R

library(ggplot2)
library(dplyr)

test <- read.csv("test.csv")

test %>% ggplot() + geom_path(aes(status,emissions)) %>% 
  facet_grid(vars(party))
  #or facet_wrap(~party)
like image 635
user3821345 Avatar asked Oct 24 '25 02:10

user3821345


1 Answers

We need + instead of %>%

library(dplyr)
library(ggplot2)
test %>%
    ggplot() + 
      geom_path(aes(status,emissions)) + 
      facet_grid(.~ party)
like image 190
akrun Avatar answered Oct 26 '25 17:10

akrun