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

From: Davendra Sohal
> 
> Hi,
> 
> I am new to R...a recent convert from SAS.
> I have a dataset that looks like this:
> 
> SEQ    A1    A2
> A    532.5    554.5
> B    25.5    35.5
> C    265.2    522.2
> D    245.55    521.56
> E    546.52    141.52
> F    243.25    32.56
> G    452.55    635.56
> H    15.14    16.54
> I    543.4    646.56
> J    54.4    654.5
> K    646.5    64.54
> L    645.4    614.46
> M    646.54    634.46
> 
> I want to make a histogram each for A1 and A2, with density 
> curves, on the same plot so that I can see how they overlap.
> 
> Please let me know some simple code for this.
> 
> I looked at ldahist but it was complicated. Anything simpler?
> 
> Thanks a lot,
> -DS.
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to