Hello there, I am using R to plot some cumulative histogram for my data. Please help in this case. Thank you Lisa Wang Princess Margaret Hospital Toronto phone 416 946 4501 ext.4883
I'm not sure what a cumulative histogram is, but does the following help? x <- rnorm(100) plot(ecdf(x)) Andy> From: Lisa Wang > > Hello there, > > I am using R to plot some cumulative histogram for my data. > Please help > in this case. > > Thank you > > Lisa Wang > Princess Margaret Hospital > Toronto > phone 416 946 4501 ext.4883 > > ______________________________________________ > R-help at 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 > >
> I am using R to plot some cumulative histogram for my data. Please help > in this case.It's not exactly a cumulative histogram, but perhaps ?ecdf is what you want: plot(ecdf(islands)) It's also possible to abuse hist to get a cumulative histogram: h <- hist(islands) h$counts <- cumsum(h$counts) plot(h) (but that was just a quick attempt so may break other code) Hadley
Selon Lisa Wang <lisawang at uhnres.utoronto.ca>:> Hello there, > > I am using R to plot some cumulative histogram for my data. Please help > in this case. > > Thank you > > Lisa WangHi Lisa, Here is one way (if i am right in what is a cumulative histogram), using the existing possibilities cumhist <- function(x, plot=TRUE, ...){ h <- hist(x, plot=FALSE, ...) h$counts <- cumsum(h$counts) h$density <- cumsum(h$density) h$itensities <- cumsum(h$itensities) if(plot) plot(h) h } R> x <- rnorm(100) R> cumhist(x) R> # hist(x, add=TRUE, col="cyan") R> # if you want to overlay the original histogram -- Romain