Совокупная гистограмма с процентами по оси Y

Я хочу построить в проекте R кумулятивную гистограмму, где по осям Y сообщается процент вместо частоты

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()

Спасибо за помощь


person Gianni Spear    schedule 12.11.2012    source источник
comment
Установите freq=FALSE в hist(data, freq=FALSE), чтобы получить процент вероятности вместо частоты   -  person Jilber Urbina    schedule 12.11.2012
comment
можно ли добавить/изменить полосу с линией?   -  person Gianni Spear    schedule 12.11.2012


Ответы (4)


Разве это не график эмпирической кумулятивной функции распределения? Как в

plot(ecdf(x))

который производит:

введите здесь описание изображения

person Gavin Simpson    schedule 12.11.2012

Для гистограммы гистограммы столбца вам нужно будет сделать:

x <- c(rnorm(100), rnorm(50, mean=2,sd=.5))
hist( x,plot=FALSE) -> h # do a histogram of y and assign its info to h
h$counts <- cumsum(h$counts)/sum(h$counts) # replace the cell freq.s by cumulative freq.s
plot( h ) # plot a cumulative histogram of y

Источник.

person Chris    schedule 13.09.2017

Также попробуйте:

plot( sort(x), (1:length(x))/length(x), type="l" )

person dlv    schedule 23.09.2014

Для аккуратного метода Попробуйте:

plot.ecdf(x)
person user9224    schedule 22.08.2018