[R] How to plot two variables in one histogram?

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Thu Mar 1 19:38:47 CET 2001


On Thu, 1 Mar 2001, LIQING ZHANG wrote:

>Is there a way I can include more than one variable in a histogram?

Yes, you can do e.g.
> x <- rpois(100, 5)
> y <- rpois(100, 4)
> hist(x)
> hist(y, add=T)

You might need to adjust ylim and xlim, add some fancy colors to
distinguish the two variables, etc., but it's the basic method.

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list