Re: [R] Part of a density plot

From: Dennis Murphy <djmuser_at_gmail.com>
Date: Sun, 20 Mar 2011 04:46:18 -0700

Hi:

Here's a lattice version:

y <- rbeta(10000, 2, 5)
densityplot( ~ y, xlim = c(0, 1), plot.points = FALSE,

            panel = function(x, y, ...) {
               p <- seq(0.001, 0.999, by = 0.001)
               panel.densityplot(x, col = 'blue', ...)
               panel.xyplot(p, dbeta(p, 2, 5), col = 'red', type = 'l', ...)
              },
            key = list(corner = c(1, 1),
                       text = list(c('Estimated', 'Beta(2, 5)')),
                       lines = list(col = c('blue', 'red')) )

Dennis

On Sat, Mar 19, 2011 at 7:15 PM, Jim Silverton <jim.silverton_at_gmail.com>wrote:

> Suupose I have
> y <- rbeta(10000, 2, 5)
> and I only want to see only the density plot from x = 0 to x = 1
> How do I do this?
>
> --
> Thanks,
> Jim.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org 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.
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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. Received on Sun 20 Mar 2011 - 11:53:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Mar 2011 - 15:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive