If I have two columns, one represents depth and the other one represent an study site. In both columns I have 1000 rows. 1000 sites and 1000 data numbers. The first 500 pieces of information represent a different site than the other 500.

How can I split the data to get two histograms with a normal density curve for each site as a panel. I used this but this puts all the data in the same histogram.

library(lattice)

histogram(~depth, data = oceans, type= 'density',main="Ocean depth",

panel = function(x, ...){

panel.histogram(x, col = "blue", ...)

panel.densityplot(x, lwd = 2, col = 'red')

})

This picture is not my work, is just the idea but inly for two sites