this is what i needed!  thank you. 

> -----Original Message-----
> From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] 
> Sent: Monday, April 13, 2009 12:50 PM
> To: Dan Dube
> Cc: r-help@r-project.org
> Subject: Re: [R] tapply output as a dataframe
> 
> 
> Dear Dan,
> 
> Try this:
> 
> do.call(rbind,a)
> 
> 
> HTH,
> 
> Jorge
> 
> 
> 
> On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube <dd...@advisen.com> wrote:
> 
> 
>       i use tapply and by often, but i always end up banging 
> my head against
>       the wall with the output.
>       
>       is there a simpler way to convert the output of the 
> following tapply to
>       a dataframe or matrix than what i have here:
>       
>       # setup data for tapply
>       dt = data.frame(bucket=rep(1:4,25),val=rnorm(100))
>       fn = function(x) {
>        ret =
>       
> c(unname(quantile(x,probs=seq(.25,.75,.25),na.rm=T)),mean(x,na.rm=T))
>       }
>       a = tapply(dt$val,dt$bucket,fn)
>       
>       # i seem to be doing way more work than i should here....
>       n = names(a)
>       mat = NULL
>       for (i in 1:length(n)) {
>        mat = rbind(mat,unname(unlist(a[i])))
>       }
>       row.names(mat) = n
>       
>       thank you!
>       
>       ______________________________________________
>       R-help@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.
>       
> 
> 
> 

______________________________________________
R-help@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.

Reply via email to