I'm using R for the analysis of my master thesis and I have a data with age categories 1 through 6 and I have different time points (1 through 7) I took the average of each time point. So now I have a 6 by 8 table and I want to make a histogram say putting the age category on the x-axis and the different time points on the y-axis to compare them.
The data:
Group.1 T0 T1 T2 T3 T4 T5 T6
1 0.52 0.64 0.65 0.54 0.87 0.65 0.73
2 0.87 0.54 0.65 0.60 0.87 0.65 0.87
3 0.97 0.48 0.65 0.60 0.87 0.36 0.88
4 0.45 0.67 0.66 0.87 0.87 0.51 0.98
5 0.70 0.99 0.84 0.88 0.87 0.54 0.98
6 0.77 0.80 0.87 NaN NaN NaN 1.00
I used the following command:
library(reshape2)
new.df<-melt(data,id.vars="Group.1")
names(new.df)=c("Group.1","variable","value")
library(ggplot2)
ggplot(data=new.df, aes(x=Group.1, y=value,fill=(variable)))+
geom_histogram()
At first I was getting an error code saying "error: Unknown parameters: binwidth, bins, pad" So I tried specifying and now I am getting an error code "Error: stat_bin() must not be used with a y aesthetic."
Can somebody help me? what I want is something like this:
Draw histograms per row over multiple columns in R
(The first one on top with multiple colors)
Thank you.
Zas