Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
From your description I assume you want both histograms and the densities all on the same chart. With existing R graphics I am not sure that there really is a simple way to do that. That aside, note that the hist function returns a list of components that includes - breaks, defining the

Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
The code below was missing the breaks= argument to hist. I had not noticed because coincidentally both give the same breaks anways thus the following corrected version gives the same plot in this case but might not in other cases. # data DF - structure(list(SEQ = structure(c(1, 2, 3, 4, 5, 6, 7,

Re: [R] Multiple density curves

2006-08-11 Thread Gabor Grothendieck
Here is one more solution. This one uses lattice. Its a bit shorter than the classic graphics solution. In the classic graphics version we used shading and color to distinguish the bars; however, grid, and therefore lattice, do not easily support shading (its possible to simulate it using low

[R] Multiple density curves

2006-08-10 Thread Davendra Sohal
Hi, I am new to R...a recent convert from SAS. I have a dataset that looks like this: SEQA1A2 A532.5554.5 B25.535.5 C265.2522.2 D245.55521.56 E546.52141.52 F243.2532.56 G452.55635.56 H15.1416.54 I543.4646.56 J

Re: [R] Multiple density curves

2006-08-10 Thread Liaw, Andy
Assuming dat is the name of the data frame, this should get you started: library(lattice) histogram(~ unlist(dat[-1]) | factor(rep(c(A1, A2), each=nrow(dat))), panel=function(...) { panel.histogram(...) panel.densityplot(...) }, type=density) Andy