[R] NTH PERCENTILE COULMNWIESE

Rui Barradas ruipbarradas at sapo.pt
Wed Jul 18 10:37:31 CEST 2012


Hello,

Try the following.


colQuant <- function(x, probs= seq(0, 1, 0.25), na.rm = FALSE,
          names = TRUE, type = 7, ...){
	apply(x, 2, quantile, probs = probs, na.rm = na.rm, names = names, type 
= type, ...)
}

mat <- matrix(rnorm(12), 4)
colQuant(mat, 0.20)
colQuant(mat, c(0.20, 0.5))


Hope this helps,

Rui Barradas

Em 18-07-2012 08:06, Rantony escreveu:
> Hi,
>
> Here i have an matrix
> mydat <-
> ABC    XYZ
> -----     ------
> 12          6
> 6             50
> 90         100
> 55           85
> 100         25
>
> i need to find the " NTH percentile "  [result should be in column-wise].
> here i have a code for NTH percenile,
>
> For eg:- if i need 20th-percentile then,
> quantile(ncol(mydat),.2)  - here i getting output for complete matrix ,But i
> need this for all the columnswise. like this,
>
> for nth percentile
>            ABC     XYZ
>            ------    -------
> 20%   10        24    [here, given percentile value is not exact result, its
> just for output format]
>
> -Its urgent !
>
> - Thanks
> Antony.
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/NTH-PERCENTILE-COULMNWIESE-tp4636839.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list