I’m sure there is an obvious and easy solution for this … but I’m drawing a complete blank on this one: how can I create a histogram and/or density plot using ALL data points in a data set that consists of several rows and columns?
Example data:
MYdata <- data.frame(Name = round(rnorm(12, 1000, 250)),
Sample1 = rnorm(12, 10000, 2500),
Sample2 = rnorm(12, 10000, 2500),
Sample3 = rnorm(12, 10000, 2500),
Sample4 = rnorm(12, 10000, 2500))
“Name” is the header of the column containing the row names. Columns Sample1 to Sample4 contain the data. hist() or geom_histogram() require an x = . But I don’t know what x is in my data set.
Thanks for your help.
Check out
meltfrom thereshape2package. Since Hadley made them bothreshape2,plyrandggplotthey play very nicely together:I used
geom_density()since your data is continuous, but changing togeom_histogram()is straight forward.