Hi I have the following columns in a table:
Person
Score1
Score2
and I can plot a historgram of the scores using qplot:
qplot(Score1,data = dat,geom="histogram")
which is fine, - but how do I plot two histograms side by side - one with Score1 and one with Score2.
I have also managed to plot both on the same graph using ggplot and melting Score1 and Score2:
m <- melt(dat[,c(2,3)])
>head(m)
variable value
1 Score1 50
2 Score2 70
3 Score1 45
4 Score2 30.5
5 Score1 70
6 Score2 40
ggplot(m,aes(value)) + geom_bar(binwidth = 1)
however when trying to use facet_wrap()
ggplot(m,aes(value)) + geom_bar(binwidth = 1) + facet_wrap(variable ~ Score_type)
I get:
Error in layout_base(data,cols,drop = drop)
At least one layer must contain all variables used for facetting
Any ideas? I will post if I solve this myself.Also is it possible to order the x axis by Score1 or Score2?
Thanks!