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.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 07-Jul-10 Time: 22:26:05 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@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.