[R] Why 95% "quantile" empty in R or why 95% "quantile" = 1 with data values between 0 and 1?

Angelr angerusso1980 at gmail.com
Tue Jul 10 02:55:12 CEST 2012


I am calling quantiles as follows. I don't understand why sometimes the
columns (data values) above 95% are returned as "NULL"!! When I drop the
percentile down to 92%, I see colums appearing. Why would any quantile be
empty? I see sometimes that 95% percentile is being chosen as "1" for my
data between 0 and 1, where obviously there's no column value equal to 1.
But why would 95% of a data be = 1 when there's clearly no value=1?

Thanks.

makeQuantiles <- function(x) {
  t(apply(x, 1, function(row) { quantile(row, probs = c(0.50,0.75, 0.90,
0.91,0.92,0.93,0.94,0.95,0.96,0.97,0.98)
) }))
}
colsGTQuantile <- function(x, qs, q) {
  sapply(rownames(x), function(rn) {
    cat(sprintf("*** row name = %s, q = %s, val = %f\n", rn, q, qs[rn, q]))
    names(x[rn, x[rn,] > qs[rn, q]])
  }, simplify = TRUE)
}


df4 <- colsGTQuantile(km$points, qs, "95%")



--
View this message in context: http://r.789695.n4.nabble.com/Why-95-quantile-empty-in-R-or-why-95-quantile-1-with-data-values-between-0-and-1-tp4635934.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list