# [R] How is the relation between Frequency and Counts in hist/density defined?

From: Tal Galili <tal.galili_at_gmail.com>
Date: Mon, 23 May 2011 17:49:29 +0300

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.

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, col = "blue", lwd = 5)

Tal

```----------------Contact
Details:-------------------------------------------------------
```
Contact me: Tal.Galili_at_gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)

[[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 Mon 23 May 2011 - 14:51:42 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

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 Mon 23 May 2011 - 15:10:09 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.