[R] Frequency table to histogram

Luc Villandre villandl at dms.umontreal.ca
Tue Apr 7 16:30:32 CEST 2009


   Hi Louisa,
   I'm still not entirely sure of what you're trying to do, but I'll attempt an
   answer to your question nevertheless.
   Let's assume that this frequency table was created from a dataset that
   comprised only a single column of "Chest" values. If you want to recreate
   this original column, you'd have to use
   temp1 = rep(temp$Chest,temp$Count) ;
   Then, you could redefine your break points and let the hist() function count
   the number of data entries in each new category.
   Hope this helps,
   Luc
   Mary Winter wrote:

     Hi,

     Sorry, yes that would be a better idea, Luc!
     Here are the first few lines of the frequency table..

     Count Chest
     1      3    33
     2     18    34
     3     81    35
     4    185    36
     5    420    37

     In my previous email I said the sample size was 100, I just meant that as
     an example, obviously it's far greater than that..

     Louisa

     > Date: Tue, 7 Apr 2009 10:00:55 -0400
     > From: [1]villandl at dms.umontreal.ca
     > To: [2]statsstudent at hotmail.com
     > CC: [3]r-help at r-project.org
     > Subject: Re: [R] Frequency table to histogram
     >
     > Hi Mary,
     >
     > Could you please provide a copy of the first few lines of your frequency
     > table (with only relevant columns)? I think this could help many
     > potential contributors understand in more details what you're trying to
     do.
     >
     > Cheers,
     >
     > Luc
     >
     > Mary Winter wrote:
     > >
     > >
     > > I have read a frequency table in to R called "temp." I now want to
     create a histogram table from it, but I obviously first have to expand the
     data - to the sample size of 100. I want to use the command rep(), but I'm
     not sure how to go about it..I tried using the code:
     > >
     > >
     > >
     > > temp1<-rep(temp$Chest,100)
     > >
     > > hist(temp1)
     > >
     > >
     > >
     > > But this creates a v. odd histogram so I know it must be wrong!
     > >
     > >
     > >
     > > Would be very grateful if any one could help me out!
     > >
     > >
     > >
     > > Mary
     > >
     > > _________________________________________________________________
     > >
     > >
     > > [[alternative HTML version deleted]]
     > >
     > > ______________________________________________
     > > [4]R-help at r-project.org mailing list
     > > [5]https://stat.ethz.ch/mailman/listinfo/r-help
     > > PLEASE do read the posting guide
     [6]http://www.R-project.org/posting-guide.html
     > > and provide commented, minimal, self-contained, reproducible code.
     > >
       ______________________________________________________________

     Surfing the web just got more rewarding. [7]Download the New Internet
     Explorer 8

References

   1. mailto:villandl at dms.umontreal.ca
   2. mailto:statsstudent at hotmail.com
   3. mailto:r-help at r-project.org
   4. mailto:R-help at r-project.org
   5. https://stat.ethz.ch/mailman/listinfo/r-help
   6. http://www.R-project.org/posting-guide.html
   7. http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U



More information about the R-help mailing list