[R] Histograms in R
R. Michael Weylandt
michael.weylandt at gmail.com
Fri Nov 4 03:36:17 CET 2011
You're absolutely right. Was thinking exponential for some reason....
The rootogram is quite nice; I've never seen one before. Thanks!
On Thu, Nov 3, 2011 at 5:39 PM, David L Carlson <dcarlson at tamu.edu> wrote:
> The lines() command doesn't work and histogram combines categories unless
> you specify the number. How about a barplot
> Lam <- 3
> X <- table(rpois(500, Lam))
> Max <- length(X)-1
> barplot(rbind(X, 500*dpois(0:Max, Lam)), beside=TRUE,
> legend.text=c("Observed", "Expected"))
> or a rootogram
> rootogram(X, dpois(0:Max, Lam)*500)
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of R. Michael Weylandt <michael.weylandt at gmail.com>
> Sent: Thursday, November 03, 2011 2:55 PM
> To: kerry1912
> Cc: r-help at r-project.org
> Subject: Re: [R] Histograms in R
> Try something like this
> Lam <- 3
> X <- rpois(500, Lam)
> hist(X, freq = F)
> x <- seq(min(X), max(X), length = 500)
> lines(x, dpois(x, Lam), col=2)
> Adapt as necessary
> On Nov 3, 2011, at 8:03 AM, kerry1912 <kerry1912 at hotmail.com> wrote:
>> We have a histogram of our observed response and we want to overlay the
>> corresponding poisson distribution with respect to our poisson model.
>> View this message in context:
>> Sent from the R help mailing list archive at Nabble.com.
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help