RE: [R] Function inside tapply

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Wed 08 Jun 2005 - 03:09:29 EST


Is this what you want to do?

> DF <- data.frame(matrix(runif(500), ncol=5))
> (DFq <- sapply(DF, quantile, probs=seq(.1, .9, by=.1)))

           X1 X2 X3 X4 X5

10% 0.1175181 0.05375085 0.1023331 0.09187593 0.1508769
20% 0.2139076 0.20185996 0.2193513 0.21401223 0.2211100
30% 0.3117315 0.30172147 0.3470629 0.32661316 0.2838589
40% 0.4309932 0.41003894 0.4008221 0.39889547 0.4093088
50% 0.5445139 0.47162199 0.4923676 0.49485975 0.5254150
60% 0.6459154 0.54170930 0.5615777 0.59523613 0.6014709
70% 0.7077307 0.70178999 0.6502444 0.64961047 0.7031002
80% 0.7625163 0.79307446 0.7496251 0.80094534 0.7800664
90% 0.8602119 0.89546621 0.8271837 0.91172347 0.8579161

Andy

> From: dscully@fd9ns01.okladot.state.ok.us
>
> I'm new to R and not an experienced writer of programs, which may help
> explain my question. I wish to create a table or data frame which
> contains the quantiles of the columns in the data frame DF.
> I wish to
> produce a table T where T[1] shows me the quantiles of column
> DF[1] right
> up through the entirety of DF. Tried several approaches with limited
> success. This looked like the best approach but I need a way
> to specify
> which quantiles I'm interested in. All I am able to achieve are the
> default vales. This only seems to be a problem when the
> quantile function
> is inside of tapply.
> T<-tapply(DF,colnames(DF),quantile ,na.rm = TRUE)
>
> ______________________________________________
> 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
>
>
>



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 Received on Wed Jun 08 03:25:52 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:27 EST