Hi all,
I'm looking to add a density smoother on top of a hist when Freq=T.
In order to do this I can use the relation between count and density, but I
would like to know if there is a way for me to predict it upfront.
Here is an example:
set.seed(242)
z = rnorm(30)
hist_z - hist(z)
In order to do this I can use the relation between count and density, but
I
would like to know if there is a way for me to predict it upfront.
In the code for hist.default, you'll see the line
dens - counts/(n * diff(breaks))
Here is an example:
set.seed(242)
z =
Thanks Richard!
Contact
Details:---
Contact me: tal.gal...@gmail.com | 972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
... Which makes the cumulative (discrete) distribution 1, as it should be.
-- Bert
On Mon, May 23, 2011 at 7:59 AM, Tal Galili tal.gal...@gmail.com wrote:
Thanks Richard!
Contact
Details:---
Contact me: tal.gal...@gmail.com
Thanks Bery and Richard.
So how would you suggest to create a histogram function with an added
density plot on top of it?
Here is what I've came up so far (ANY suggestion for improvement will be
welcomed!):
#-
# function
try this -- it scales to the maximum value:
set.seed(242)
z = rnorm(30)
hist_z - hist(z)
hist_z$counts / hist_z$density # the relation is 15
# why is this 15 ??
# So I can now do:
hist(z)
# change in this statement - scale to the max
y - density(z)$y * max(hist_z$counts) / max(density(z)$y)
#is
Check the Help archives, google, search cran, as this has been
requested many times. IIRC, Greg Snow's gtools package has a function
that does this.
-- Bert
On Mon, May 23, 2011 at 8:39 AM, Tal Galili tal.gal...@gmail.com wrote:
Thanks Bery and Richard.
So how would you suggest to create a
7 matches
Mail list logo