Re: [R] histogram

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 08 May 2008 20:49:23 -0400

Hi all,

Why not only?

set.seed(54321)
 X <- 5*rnorm(500)
hist(X,label=TRUE,ylim=c(0,200))

Thanks,

Jorge

On Thu, May 8, 2008 at 8:26 PM, Ted Harding <Ted.Harding_at_manchester.ac.uk> wrote:

> On 09-May-08 00:12:46, David Scott wrote:
> > On Thu, 8 May 2008, Roslina Zakaria wrote:
> >
> >> Dear R-expert,
> >> For histogram function, can we get the table of bin and
> >> frequency like in excel, together with the histogram?
> >> Therefore, we can check the number of data included.
> >> Thank you so much for your attention and help.
> >
> > Easy one: just use the argument plot=FALSE and hist will produce the
> > counts etc for you
> >
> > David Scott
>
> Well, there's a slightly nicer way than that! (Don't forget that
> we're competing with Excel here ... ).
>
> Since the value of hist() includes breakpoints and counts,
> you can get the plot and the table as follows:
>
> set.seed(54321)
> X <- 5*rnorm(500)
> H<-hist(X) ### Here you get the histogram drawn
> B<-H$breaks ; C<-H$counts ; k<-length(B)
> cbind(From=B[1:(k-1)],To=B[2:k],Count=C) ### Here bins and frequencies
> # From To Count
> #[1,] -15 -10 16
> #[2,] -10 -5 69
> #[3,] -5 0 181
> #[4,] 0 5 149
> #[5,] 5 10 71
> #[6,] 10 15 14
>
> So we can indeed "get the table of bin and frequency like
> in excel, together with the histogram".
>
> Best wishes to all,
> Ted.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 09-May-08 Time: 01:26:35
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> 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 Fri 09 May 2008 - 00:51:21 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 Fri 09 May 2008 - 02:30:36 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