On 15-Aug-07 08:30:08, Nick Chorley wrote: > Hi, > > I have a large amount of data that I would like to create a > histogram of and plot and do things with in R. It is pretty > much impossible to read the data into R, so I have written a > program to bin the data and now have a list of counts in each > bin. Is it possible to somehow import this into R and use > hist(), so I can, for instance, plot the probability density? > I have looked at the help page for hist(), but couldn't find > anything related to this there. > > Regards, > > Nicky Chorley
Presumably you now have (or can readily generate) files on your system whose contents are (or are equivalent to) something like: brkpts.dat 0.0 0.5 1.0 .... 9.5 10.0 counts.dat 10 7 38 .... 7 0 where there is one more line in brkpts.dat than in counts.dat Now simply read both files into R, creating variables 'brkpts', 'counts' Now create a histogram template (any silly old data will do): H1 <- hist(c(1,2)) Next, attach your variables to it: H1$breaks <- brkpts H1$counts <- counts and you have your histogram in R. Also, you can use the data in the variables 'brkpts', 'counts' to feed into any other procedure which can acept data in this form. Example (simulating the above in R): brkpts<-0.5*(0:20) counts<-rpois(20,7.5) H1<-hist(c(1,2)) H1$breaks <- brkpts H1$counts <- counts plot(H1) Or, if you want a more "realistic-looking" one, follow on with: midpts<-(brkpts[1:20]+brkpts[2:21])/2 counts<-rpois(20,100*dnorm(midpts,mean=5,sd=3)) H1$breaks <- brkpts H1$counts <- counts plot(H1) In other words, you've already done R's work for it with your program which bins the data. All you need to do in R is to get these results into the right place in R. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 15-Aug-07 Time: 10:38:05 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@stat.math.ethz.ch 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.