Mike Cheung <[EMAIL PROTECTED]> writes: > I know that "ecdf" can be used to calculate the empirical cumulative > distribution. However, I don't know how to exact the cumulative > probabilities for each unique element. The requirement is similar to > the "FREQUENCIES" in SPSS. Could someone help me in exacting the > cumulative probabilities from the ecdf object? Thanks in advance! > > # Generating artificial data > x <- round( rnorm(50, mean=50, sd=10) ) > probs <- seq(0.1, 0.9, by=0.1) > # Calculating percentiles > x.percentiles <- quantile(x, probs) > # Calculating percentile ranks > x.ranks <- ecdf(x)
I don't quite see why you call it "x.ranks", but it's just a function that you could evaluate at the step points, so continuing your code: val <- sort(unique(x)) cbind(val,cum.prop=x.ranks(val)) I'd go for a more direct approach though: cumsum(prop.table(table(x))) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ 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