[R] Histogram question
Liaw, Andy
andy_liaw at merck.com
Tue Sep 2 14:35:54 CEST 2003
You can do it "by hand"; e.g.,
x <- rnorm(50)
x.hist <- hist(x, prob=TRUE, plot=FALSE)
x.prob <- x.hist$count / length(x)
## Alternatively:
x.prob <- diff(x.hist$breaks) * x.hist$density
You can then use barplot or whatever you like to plot x.prob.
HTH,
Andy
> -----Original Message-----
> From: Erin Hodgess [mailto:hodgess at gator.dt.uh.edu]
> Sent: Tuesday, September 02, 2003 4:38 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Histogram question
>
>
> Dear R People:
>
> When the "hist" command is used with the probability = T, the
> results are such that the height x the width of each bar
> would represent the relative frequency.
>
> Is there a way to adjust the hist function such that the bars
> have the
> height of the relative frequency (without regard to width), please?
>
> I was experimenting with the "truehist" function and changed
> the code for the "est" value. However, the y axis labels are
> not at the same levels between the prob = T and prob = F when
> that change is made.
>
> This is R 1.7.1 for Windows.
>
> thanks in advance!!!!!
>
> Sincerely,
> Erin Hodgess
> mailto: hodgess at gator.uhd.edu
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
>
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments,...{{dropped}}
More information about the R-help
mailing list