Hello, I just need a hint here: Suppose I have no raw data, but only a frequency table I have, and I want to run basic statistical procedures with it, like histogram, descriptive statistics, etc. How do I do this with R? For example, how do I plot a histogram for this table for a sample of size 60? Value Count 1 10 2 8 3 12 4 9 5 14 6 7 Thanks, A.Z.
On 07-Jul-10 20:39:32, Andrei Zorine wrote:> Hello, > I just need a hint here: > Suppose I have no raw data, but only a frequency table I have, and I > want to run basic statistical procedures with it, like histogram, > descriptive statistics, etc. How do I do this with R? > For example, how do I plot a histogram for this table for a sample of > size 60? > > Value Count > 1 10 > 2 8 > 3 12 > 4 9 > 5 14 > 6 7 > > > Thanks, > A.Z.You could use the data with barplot(O) -- see '?barplot' -- to emulate a histogram; or you could do it with your "bare hands" by using the data to draw your own boxes. Another approach (which is slightly "naughty") is along the following lines. First a "dummy histogram" object H is created, then its main components (for your purpose) 'breaks' and 'counts' are matched to the data; and then you plot it: H <- hist(1,plot=FALSE) H$breaks <- 0.5+(0:6) H$counts <- c(10,8,12,9,14,7) plot(H,main="Example") Note, however, that if you inspect what is in H by simply entering H you will find that the components $intensities $density have not been properly set. Nevertheless, the above is a relatively painless way of getting a standard histogram plot from such data. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 07-Jul-10 Time: 22:26:05 ------------------------------ XFMail ------------------------------
See Teds answer for histogram (I'd go with barplot). For most statistical procedures there is a weighted version (e.g. weighted.mean() for the mean). Your counts are valid weights for most procedures. Cheers Joris On Wed, Jul 7, 2010 at 10:39 PM, Andrei Zorine <zoav1602 at gmail.com> wrote:> Hello, > I just need a hint here: > Suppose I have no raw data, but only a frequency table I have, and I > want to run basic statistical procedures with it, like histogram, > descriptive statistics, etc. How do I do this with R? > For example, how do I plot a histogram for this table for a sample of size 60? > > Value ? Count > 1 ? ? ? 10 > 2 ? ? ? 8 > 3 ? ? ? 12 > 4 ? ? ? 9 > 5 ? ? ? 14 > 6 ? ? ? 7 > > > Thanks, > A.Z. > > ______________________________________________ > 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. >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
A.Z., You could recreate the data (I assumed that the values are discrete integers and not a bin for a continuous variable) ... value <- 1:6 count <- c(10,8,12,9,14,7) d <- rep(value,count) table(d) ... and then do what you want with the data in the d vector ... summary(d) hist(d)> On 07-Jul-10 20:39:32, Andrei Zorine wrote: > > Hello, > > I just need a hint here: > > Suppose I have no raw data, but only a frequency table I have, and I > > want to run basic statistical procedures with it, like histogram, > > descriptive statistics, etc. How do I do this with R? > > For example, how do I plot a histogram for this table for a sample of > > size 60? > > > > Value Count > > 1 10 > > 2 8 > > 3 12 > > 4 9 > > 5 14 > > 6 7 > > > > Thanks, > > A.Z.