[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 PERCENTSLEEPDAY1BOUTLENGTHTOT1 [7] BOUTLENGTHNITE1 BOUTLENGTHDAY1 BOUTTHRESTOTP1 [10]

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 mst...@gmail.com 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]

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] PERCENTSLEEPNIGHT1

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 djmu...@gmail.com wrote: Try this: nms - paste(BOUTLENGTHTOT, 1:17, sep = ) data[, nms] On Thu, Jan 14, 2010 at 2:08 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Try dat[names(dat) %in% paste(BOUTLENGTHTOT, 1:17, sep=)] Thanks! Both