Displaying 1 result from an estimated 1 matches for "hist_z".
2011 May 23
1
How is the relation between Frequency and Counts in hist/density defined?
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)
hist_z$counts / hist_z$density # the relation is 15
# why is this 15 ??
# So I can now do:
hist(z)
y <- density(z)$y * max(hist_z$counts / hist_z$density, na.rm = T) # this
is what I hope to find without using hist, and only using density
x <- density(z)$x
lines(x = x, y = y, c...