Re: [R] column selection for aggregate()

2010-01-19 Thread Ivan Calandra
Not really, I tried without select = - c(MEASUREM, SEL_FACET, SEL_MEAS) and indeed the mean was not computed, but it still appeared in the data, which I didn't want. Thanks a lot for your help Ivan Gabor Grothendieck a écrit : > It looks ok except you have both specified the wanted factors and

Re: [R] column selection for aggregate()

2010-01-19 Thread Petr PIKAL
Hi If I really wanted aggregate all numerics by all non numerics this is how I would do it my.numerics <- which(sapply(zeta, is.numeric)) my.factor <- which(sapply(zeta, is.factor)) aggregate(zeta[, my.numerics], zeta[, my.factor], mean) Regards Petr r-help-boun...@r-project.org napsal dne 1

Re: [R] column selection for aggregate()

2010-01-18 Thread Gabor Grothendieck
It looks ok except you have both specified the wanted factors and removed the undesired factors from the data frame. You only need to do one of these as in the example I gave, not both, so the solution could be simpler. On Mon, Jan 18, 2010 at 11:19 AM, Ivan Calandra wrote: > Hi! > > It looks li

Re: [R] column selection for aggregate()

2010-01-18 Thread Ivan Calandra
Hi! It looks like it works perfectly. However, since I cannot check whether I get the good result or not, can you please let me know if you see any mistakes? Here is the code: ssfamean <- summaryBy(.~SPECSHOR+BONE+TO_POS+FACETTE+SHEARFAC+ENA_BA, data = subset(ssfa, select = - c(MEASUREM, SEL_FA

Re: [R] column selection for aggregate()

2010-01-18 Thread Gabor Grothendieck
Try summaryBy in the doBy package. e.g. using the built-in CO2 summarize each numeric variable by each factor except for the factors Plant and Type: library(doBy) summaryBy(. ~ ., data = subset(CO2, select = - c(Plant, Type))) On Mon, Jan 18, 2010 at 9:53 AM, Ivan Calandra wrote: > Hi everybody

Re: [R] column selection for aggregate()

2010-01-18 Thread b k
On Mon, Jan 18, 2010 at 10:33 AM, Ivan Calandra < ivan.calan...@uni-hamburg.de> wrote: > 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 categ

Re: [R] column selection for aggregate()

2010-01-18 Thread Ivan Calandra
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

Re: [R] column selection for aggregate()

2010-01-18 Thread b k
On Mon, Jan 18, 2010 at 10:17 AM, Ivan Calandra < 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

Re: [R] column selection for aggregate()

2010-01-18 Thread Ivan Calandra
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 I think I've tried everything tha

Re: [R] column selection for aggregate()

2010-01-18 Thread b k
On Mon, Jan 18, 2010 at 9:53 AM, Ivan Calandra wrote: > Hi everybody! > > I'm working on R today so I have a lot of questions (you may have > noticed that it's the 3rd email today). I'm new on R, so please excuse > the "spam"! > > I have a dataset "ssfa" with many rows and the column names are: >

[R] column selection for aggregate()

2010-01-18 Thread Ivan Calandra
Hi everybody! I'm working on R today so I have a lot of questions (you may have noticed that it's the 3rd email today). I'm new on R, so please excuse the "spam"! I have a dataset "ssfa" with many rows and the column names are: > names(ssfa) [1] "SPECSHOR" "BONE" "TO_POS""MEASUREM"