I'm trying do display multiple histograms with one plot with the lattice-package.
That's my code so far:
histogram(~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10, data=mydata,
type = "density",layout=c(5,2),
panel=function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath=dnorm, col="black",
args=list(mean=mean(x), sd=sd(x)), ...)
})
The problem is, that it won't plot the probability-curve. It doesn't give me an error back, so the code looks good, I think.
I also tried it with only one variable and it didn't work either:
histogram(~ X1, data=mydata,
type = "density",layout=c(5,2),
panel=function(x, ...) {
panel.histogram(x, ...)
panel.mathdensity(dmath=dnorm, col="black",
args=list(mean=mean(x), sd=sd(x)), ...)
})
Does anyone see an error in my code? Or could be something wrong in my data?
I'm glad for any advice!