[R] Need help on having multiple distributions in one graph

jhilbe at aol.com jhilbe at aol.com
Tue May 4 00:42:10 CEST 2010


R-listers:

I have searched the help files and everything I have related to R 
graphics. I cannot find how to graph y against
several distributions on a single graph. Here is code for creating 4 
Poisson distributions with different mean values, although I would 
prefer having it in a loop: The top of the y axis for the first 
distribution, with count of 0, is .6, which is the highest point for 
any  of the distributions.

obs <- 1:20 
y <- obs-1
m0 <- (exp(-.5) * .5^y)/factorial(y)
m1 <- (exp(-1) * 1^y)/factorial(y)
m3 <- (exp(-3) * 3^y)/factorial(y)
m4 <- (exp(-5) * 5^y)/factorial(y)

How do I plot the graph of each distribution on y, all on a single 
graph? I have spent so many hours on this,
which is really quite simple in applications such as Stata. Thanks very 
much for the assistance:

Joseph Hilbe
hilbe at asu.edu  or jhilbe at aol.com



More information about the R-help mailing list