[R] filling a vector with a tapply function applied to another vector

Petr PIKAL petr.pikal at precheza.cz
Fri Nov 12 14:45:31 CET 2010


Hi

Use ave instead of tapply. It is designed for such task

Regards
Petr
r-help-bounces at r-project.org napsal dne 12.11.2010 10:49:17:

> albechan <alberto.casetta at satt.biz> 
> Odeslal: r-help-bounces at r-project.org
> 
> 12.11.2010 10:49
> 
> Re: [R] filling a vector with a tapply function applied to another 
vector
> 
> 
> The first column has 331 rows, the number of factors in the second 
column is
> 20 repeated in order to have 331 rows too. What I need is to reapeat in 
the
> third column each of the 20 results derived from
> tapply(firstcolumn,secondcolumn,mean) as many times as each factor 
appears
> in the second column. So I'll have 331 values in the third column as 
well. 
> I hope it's clear enough what I need to do.
> 
> -- 
> View this message in context: 
http://r.789695.n4.nabble.com/filling-a-vector-
> with-a-tapply-function-applied-to-another-vector-tp3039271p3039337.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