[R] Plotting Binned Data

Ben Bolker bolker at ufl.edu
Wed Feb 18 15:08:06 CET 2009




Gundala Viswanath wrote:
> 
> Dear all,
> 
> I have a binned data that looks like this:
> 
>> dat
>   (-1,9]   (9,19]  (19,29]  (29,39]  (39,49]  (49,59]  (59,69]  (69,79]
> 10063374       79       16        4        3        4        4        3
>  (79,89]  (89,99]
>        6        2
> 
> I tried to plot a histogram overlayed with curve.
> With the following snippet:
> 
> library(lattice)
> pdf("myfile.pdf")
> 
> hist(dat)
> lines(dat,col="red")
> dev.off()
> __ END__
> 
> 

I think barplot is what you want: something like
barplot(dat,names.arg=names(dat))

  Are you sure you want to keep the first element
of dat?  You're certainly not going to be able to
see anything that's going on with the other
values ...

barplot(dat[-1],names.arg=names(dat)[-1])

  Ben Bolker

-- 
View this message in context: http://www.nabble.com/Plotting-Binned-Data-tp22071819p22079522.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list