I have a dataset looking like this:
#ID   CWRES
#1    0.90000
#1    0.59034
#1    1.81300
#1    1.42920
#1    0.59194
#2    1.90000
#2    1.09034
#2    2.01300
#2    0.42920
#2    0.19194
#...
#40   1.90000
#40   1.59034
#40   0.81300
#40   0.42920
#40   0.59194
That is one variable (CWRES) and 40 individuals (ID) I want to plot an histogram of every ID in a loop using ggplot. I know how to do it with a "normal" syntax, but I am not able to translate this syntax in ggplot.
Here is the "normal" syntax:
#attach(tab)
#for(i in unique(ID)) { 
#    j = ID==i
#    hist(CWRES,probability = T, ylab="Frequency",xlab=paste(CWRES_label),
#         col="grey90",cex=1,main=paste(paste("ID: #",i,sep="")),nclass=20)
#    lines(
#      density(CWRES,col="blue",lwd=2,lty=1))
#    box()
#    abline(v=mean(CWRES),col="blue",lwd=2)
#    abline(v=quantile(CWRES,0.025),col="blue",lwd=2,lty=2)
#    abline(v=quantile(CWRES,0.50),col="blue",lwd=2,lty=2)
#    abline(v=quantile(CWRES,0.975),col="blue",lwd=2,lty=2)
#}
#detach()
Does anybody know how to translate this in to ggplot syntax?
Thank you very much in advance,
Best regards,
Mario
 
    