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.
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)
.
Looks like ggplot does not found 'model' and /or 'name' column in your dataframe WeeklyYield.
You should check with names(WeeklyYield)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With