I wish to plot in R project a cumulative histogram where on the Y axes is reported the percentage instead of the frequency
x <- c(rnorm(100), rnorm(50, mean=2,sd=.5))
h <- hist(x, plot=FALSE, breaks=20)
h$counts <- cumsum(h$counts)
h$density <- cumsum(h$density)
plot(h, freq=TRUE, main="(Cumulative) histogram of x", col="white", border="black")
box()
Thanks for help
A cumulative histogram counts the cumulative cases over the range of cases; using the Salem data, it tells what percentage of the total number of cases accumulated each month and, therefore, how much of the outbreak had taken place.
A histogram which shows the proportion instead of the absolute amount can easily produced by weighting the data with 1/n , where n is the number of datapoints. Then a PercentFormatter can be used to show the proportion (e.g. 0.45 ) as percentage ( 45% ).
a running total of the percentage values occurring across a set of responses. The total will either remain the same or increase, reaching the highest value of 100% after totaling all of the previous percentages.
Isn't this a plot of the empirical cumulative distribution function? As in
plot(ecdf(x))
which produces:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With