I didn't understand from the help what really does the function rowMeans 
but it looks like it doesn't take into account the categorical variables 
(I want to calculate the means when the values of all categorical 
variables are the same, second part of aggregate). Moreover, ssfa_num 
contains only numeric variables, meaning that the categories will not be 
associated with it.
I'm kind of confused with this approach.
You think it would work for me?

Thanks
Ivan

b k a écrit :
>
>
> On Mon, Jan 18, 2010 at 10:17 AM, Ivan Calandra 
> <ivan.calan...@uni-hamburg.de <mailto:ivan.calan...@uni-hamburg.de>> 
> wrote:
>
>     Thanks for your answer, but it doesn't work...
>
>     Here is what I get:
>     > ssfamean <- aggregate(ssfa[[10:24]],ssfa[c("SPECSHOR", "BONE",
>     "TO_POS", "FACETTE", "SHEARFAC", "ENA_BA")],mean)
>     Error in .subset2(x, i, exact = exact) :
>       recursive indexing failed at level 2
>
>  
> Wouldn't you be better off with rowMeans() ? Split your dataframe into 
> numeric matrix:
>  
> ssfa_num  <- ssfa[10:24]
>  
> ssfameans <- rowMeans(ssfa_num)
>  
>
>     Also col_index <- match("Asfc", ssfa) doesn't really work since
>     col_index is composed of 1227 NAs...
>
>
>      
>
>  
> Yes, it should be:
>  
> col_index <- match("Asfc", names(ssfa))
>  
> Ben

        [[alternative HTML version deleted]]

______________________________________________
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