Re: [R] Extracting columns

2012-11-08 Thread arun
6 #8   30  73  12 #9   89  67   8 #10  11   8  97 A.K. - Original Message ----- From: Silvano Cesar da Costa To: arun Cc: Sent: Thursday, November 8, 2012 3:22 PM Subject: Re: [R] Extracting columns Thanks Arun, but the columns need be unique. > # Arun: > list1 <- lapply(1:5, f

Re: [R] Extracting columns

2012-11-08 Thread arun
- Original Message - From: Silvano Cesar da Costa To: r-help@r-project.org Cc: Sent: Thursday, November 8, 2012 10:50 AM Subject: [R] Extracting columns Hi, I have 22 files (A1, A2, ..., A22) with different number of columns, totaling 10,000 columns: c1, c2, c3, ..., c1 I have a

Re: [R] Extracting columns

2012-11-08 Thread Rui Barradas
Hello, Something like this should get you close. filenames <- paste0("A", 1:22) cols <- c('c1', 'c50', 'C750') lapply(filenames, function(x){ dat <- read.table(x, header = TRUE) subset(dat, select = which(names(dat) %in% cols)) }) Hope this helps, Rui Barradas Em 08-11-2012 15:50, S

[R] Extracting columns

2012-11-08 Thread Silvano Cesar da Costa
Hi, I have 22 files (A1, A2, ..., A22) with different number of columns, totaling 10,000 columns: c1, c2, c3, ..., c1 I have another file with a list of 100 columns that I need to extract. These 100 columns are distributed in 22 files. How to extract the 100 columns of the 22 files? I have

Re: [R] Extracting columns with specific string in their names

2011-08-22 Thread David Winsemius
On Aug 22, 2011, at 1:45 PM, Dennis Murphy wrote: Hi: You need a leading ^ in your grep string. Here's a reproducible example to illustrate: df <- data.frame(Xyz1 = rnorm(5), Xyz2 = rnorm(5), Xyz3 = rnorm(5), Abc1 = rnorm(5), Abc2 = rnorm(5)) df[, grep('^Xyz', names(df))] df[

Re: [R] Extracting columns with specific string in their names

2011-08-22 Thread Dennis Murphy
Hi: You need a leading ^ in your grep string. Here's a reproducible example to illustrate: df <- data.frame(Xyz1 = rnorm(5), Xyz2 = rnorm(5), Xyz3 = rnorm(5), Abc1 = rnorm(5), Abc2 = rnorm(5)) df[, grep('^Xyz', names(df))] df[, grep('^Abc', names(df))] HTH, Dennis On Mon, Aug

Re: [R] Extracting columns with specific string in their names

2011-08-22 Thread Jay
Sorry, my mistake. The thing is that the command return no results at all. However, when I just tried a simpler version of this (I had no capital letters or no spaces in the string), it worked fine. I cant figure it out, I think it all boils down to the fact that I'm no expert at regexp's... On

Re: [R] Extracting columns with specific string in their names

2011-08-22 Thread R. Michael Weylandt
Can you say a little more about what you mean "it does not work"? I'd guess you have a regular expression mistake and are probably getting more columns than desired, but without an example, it's hard to be certain. Use dput() and head() to give a small cut-and-paste-able example. Michael On Mon,

[R] Extracting columns with specific string in their names

2011-08-22 Thread Jay
Hi, Let's say that I have a set of column names that begin with the string "Xyz". How do I extract these specific columns? I tried to do the following: dataframe1[,grep("Xyz",colnames(dataframe1))] But it does not work. What is wrong with my expression? _

Re: [R] Extracting columns from a class

2011-03-19 Thread Thomas Levine
Hi, Here is the prcomp output. tom=prcomp(matrix(rnorm(25),5,5)) R functions often output lists. To see what's in this one, run "names(tom)" or type "tom$" and use tab completion. Once you do that, the following is more obvious. pc1=tom$rotation[,1] sd1=tom$sdev[1] column=c(sd1,pc1) write.tabl

[R] Extracting columns from a class

2011-03-17 Thread nuncio m
Hi list, I am not a frequent user of R. Recently I used R in principal component analysis and got the result as a class, which has information like standard deviation and principal components from 1 to 10. How is it possible to extract the column corresponding to first principal compon

Re: [R] extracting columns

2010-08-28 Thread David Winsemius
On Aug 28, 2010, at 1:24 PM, Laetitia Schmid wrote: Hi, Can anybody show me how to extract all columns in my dataset that are polymorphic? Or phrased in another way I would like to delete all columns that have no more than one letter in it (that are monomorphic). Assuming you read this

Re: [R] extracting columns

2010-08-28 Thread Laetitia Schmid
Wow. That was fast. And it works. Thank you! Laetitia Am 29.08.2010 um 00:35 schrieb Jorge Ivan Velez: > index <- apply(d, 2, function(x) length(table(x)) > 1) > d[, index] [[alternative HTML version deleted]] __ R-help@r-project.org mailin

[R] extracting columns

2010-08-28 Thread Laetitia Schmid
Hi, Can anybody show me how to extract all columns in my dataset that are polymorphic? Or phrased in another way I would like to delete all columns that have no more than one letter in it (that are monomorphic). Thank you. Laetitia "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8" "V9" "V10" "V11" "

Re: [R] extracting columns with same partial name

2010-01-14 Thread Martin Striz
On Thu, Jan 14, 2010 at 1:57 PM, Dennis Murphy wrote: > Try this: > > nms <- paste("BOUTLENGTHTOT", 1:17, sep = "") > data[, nms] > On Thu, Jan 14, 2010 at 2:08 PM, Peter Ehlers wrote: > Try > > dat[names(dat) %in% paste("BOUTLENGTHTOT", 1:17, sep="")] > Thanks! Both methods worked. --Mar

Re: [R] extracting columns with same partial name

2010-01-14 Thread Peter Ehlers
Try dat[names(dat) %in% paste("BOUTLENGTHTOT", 1:17, sep="")] -Peter Ehlers Martin Striz wrote: Hi folks, I'm new to the list. I have a data file with 256 columns. Here's just a subset of names(data): [1] "MOUSE" "BASEDATE1" "PERCENTSLEEPTOT1" [4] "PERCENTSLEEPN

Re: [R] extracting columns with same partial name

2010-01-14 Thread Henrique Dallazuanna
Try this: DF[,grep("BOUTLENGTHTOT", l)] On Thu, Jan 14, 2010 at 4:43 PM, Martin Striz wrote: > Hi folks, I'm new to the list. > > I have a data file with 256 columns.  Here's just a subset of names(data): > >  [1] "MOUSE"               "BASEDATE1"           "PERCENTSLEEPTOT1" >  [4] "PERCENTSLEE

[R] extracting columns with same partial name

2010-01-14 Thread Martin Striz
Hi folks, I'm new to the list. I have a data file with 256 columns. Here's just a subset of names(data): [1] "MOUSE" "BASEDATE1" "PERCENTSLEEPTOT1" [4] "PERCENTSLEEPNIGHT1" "PERCENTSLEEPDAY1""BOUTLENGTHTOT1" [7] "BOUTLENGTHNITE1" "BOUTLENGTHDAY1" "BOUT

Re: [R] extracting columns from a list

2008-05-23 Thread Vincent Goulet
Le ven. 23 mai à 09:37, mohamed nur anisah a écrit : Dear all, i have 2 lists of data with each of the list contain 14 columns. No, you have one list with two elements; each is a 14-column data frame. How am i going to extract column 12 and 13 from each of the list ?? Let's call your lis

Re: [R] extracting columns from a list

2008-05-23 Thread N. Lapidus
I forgot to answer to the last part of your question. I think what you call a list is actually an element of a list, right? If so, the command you want depends on the way you want to combine these elements. For example, the following lines will extract columns 12 and 13 of any array-like element o

Re: [R] extracting columns from a list

2008-05-23 Thread N. Lapidus
Hi Mohamed Try: lapply (NameOfYourList, function (dat, NumCol) dat[,NumCol], c(12,13)) But there must be a shorter way to write this. Nael On Fri, May 23, 2008 at 3:37 PM, mohamed nur anisah < [EMAIL PROTECTED]> wrote: > Dear all, > > i have 2 lists of data with each of the list contain 14 c

[R] extracting columns from a list

2008-05-23 Thread mohamed nur anisah
Dear all, i have 2 lists of data with each of the list contain 14 columns. How am i going to extract column 12 and 13 from each of the list ?? and can i combine my extracted columns to form a single list. Attach with are my data. Your coorperation is highly appreciated. Many thanks R