I am tring to plot(boxplots) multiple continuous variables (about 20 variables) with one binary outcome variable (either 0 or 1).
data:
ID outcome var1 var2 var3 var4 var5
1 0 62 2.01 13 1.94 8
2 0 150 4.32 9 99 6
3 0 18 1.86 0.6 99 22
4 0 60 4.08 3 -99 6
5 1 20 1.96 1 99 14
6 1 100 1.64 19 -99 3
my code:
tmp <- melt(data, id.vars=c("ID", "outcome"))
p <- ggplot(data = tmp, aes(x=outcome, y= value)) +
geom_boxplot(aes(fill=Label))
p + facet_wrap( ~ variable, scales="free")
this code shows the following error:
Error in layout_base(data, vars, drop = drop) : At least one layer must contain all variables used for facetting
Any help would be greatly appreciated.