5

I am using the command

qplot(factor(ww), WeeklyYield, geom = "bar", fill = I("grey50"))+facet_wrap(~model+name)

to create a bar chart for every combination of model and name. However I get the following error message:

Error in layout_base(data, vars, drop = drop) : At least one layer must contain all variables used for facetting

I cannot uncode this message.

The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
user2145299
  • 81
  • 2
  • 3
  • 8

2 Answers2

8

I'm not sure if it still helps after so much time, but I suspect the problem is that you're feeding a formula into facet_wrap(), whereas it can only take a variable, e.g. facet_wrap(~model).

If you want a formula, try facet_grid() as an alternative, e.g. facet_grid(.~model+name).

cmbosancianu
  • 159
  • 1
  • 6
3

Looks like ggplot does not found 'model' and /or 'name' column in your dataframe WeeklyYield. You should check with names(WeeklyYield)

b_rousseau
  • 159
  • 8