Re: [R] column selection

2013-01-02 Thread arun
HI, May be this helps: set.seed(5) dat1<-as.data.frame(matrix(sample(1:100,100,replace=TRUE),ncol=20)) dat1[,8:ncol(dat1)] A.K. - Original Message - From: eliza botto To: "r-help@r-project.org" Cc: Sent: Wednesday, January 2, 2013 8:59 AM Subject: [R] column selec

Re: [R] column selection

2013-01-02 Thread ONKELINX, Thierry
ject.org [mailto:r-help-boun...@r-project.org] Namens eliza botto Verzonden: woensdag 2 januari 2013 15:00 Aan: r-help@r-project.org Onderwerp: [R] column selection Dear R users, sorry for a very basic question. i wanted to ask that if your column are too much in number and you want to se

Re: [R] column selection

2013-01-02 Thread Jorge I Velez
Hmmm... May be q[, 117:ncol(q)] And, by the way, do not use "q" as the name for your data.frame() or matrix() as it is a reserved name. See ?q and require(fortunes) fortune('dog') for reasons why. HTH, Jorge.- On Thu, Jan 3, 2013 at 12:59 AM, eliza botto <> wrote: > > Dear R users, > sorry

Re: [R] column selection

2013-01-02 Thread Berend Hasselman
On 02-01-2013, at 14:59, eliza botto wrote: > > Dear R users, > sorry for a very basic question. i wanted to ask that if your column are too > much in number and you want to select the remaining columns, starting from > column number 117. one way is to use usual command >> q[ ,(117:2300)].

[R] column selection

2013-01-02 Thread eliza botto
Dear R users, sorry for a very basic question. i wanted to ask that if your column are too much in number and you want to select the remaining columns, starting from column number 117. one way is to use usual command >q[ ,(117:2300)]. is there a way by which i can select the remaining columns

Re: [R] column selection in list

2010-01-25 Thread Adaikalavan Ramasamy
If the columns of all elements of the list are in the same order, then you can collapse it first and then extract. out <- do.call("rbind", SPECSHOR_tx_Asfc) out[ , "Asfc.median"] Regards, Adai Ivan Calandra wrote: Hi everybody! I have a (stupid) question but I cannot find a way to do

Re: [R] column selection in list

2010-01-25 Thread Ivan Calandra
Thanks, I didn't think about the help for such a character. Ivan Le 1/22/2010 18:50, baptiste auguie a écrit : ?"[" should give you enough information. In short, "[" is an operator to extract elements, you can think of it as a function with special semantics. For a simple vector, v = c("one", "

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
?"[" should give you enough information. In short, "[" is an operator to extract elements, you can think of it as a function with special semantics. For a simple vector, v = c("one", "two") v[2] selects the second element of the vector, and is equivalent to, `[`(v, 2) # "two" as you can see fro

Re: [R] column selection in list

2010-01-22 Thread Ivan Calandra
Thanks Baptiste, it does help. However, I don't really understand what "[" means. Could you please tell me more about it? I didn't find anything helpful on that in the help. Thanks in advance Ivan Le 1/22/2010 17:19, baptiste auguie a écrit : Hi, Try this, a = replicate(3, data.frame(x=1

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
Hi, Try this, a = replicate(3, data.frame(x=1:10, y=rnorm(10)), simplify=FALSE) lapply(a, "[", "y") HTH, baptiste 2010/1/22 Ivan Calandra : > Hi everybody! > > I have a (stupid) question but I cannot find a way to do it! > > I have a list like: >> SPECSHOR_tx_Asfc > $cotau >   SPECSHOR Asfc.m

[R] column selection in list

2010-01-22 Thread Ivan Calandra
Hi everybody! I have a (stupid) question but I cannot find a way to do it! I have a list like: > SPECSHOR_tx_Asfc $cotau SPECSHOR Asfc.median 38cotau381.0247 39cotau154.6280 40cotau303.3219 41cotau351.2933 42cotau156.5327 $eqgre SPECSHOR Asfc.median

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"