Re: [R] Subsetting problem data, 2

2012-07-20 Thread Lib Gray
I'm getting this error message: nms-names(data)[grep(vars,names(data))] Warning message: In grep(vars, names(data)) : argument 'pattern' has length 1 and only the first element will be used Is there a way around this? On Thu, Jul 19, 2012 at 6:17 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

Re: [R] Subsetting problem data, 2

2012-07-20 Thread Lib Gray
I'm still getting the message (if this is what you were suggesting I try). The data set I'm using has many more columns other than these variables; could that be a problem? I didn't think it would affect it. pattern - L[1-8][12] nms-names(data)[grep(vars,names(data))] Warning message: In

Re: [R] Subsetting problem data, 2

2012-07-20 Thread Chris Campbell
) 1249 705 450 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lib Gray Sent: 20 July 2012 01:17 To: Rui Barradas Cc: r-help Subject: Re: [R] Subsetting problem data, 2 I'm still getting the message (if this is what you were

Re: [R] Subsetting problem data, 2

2012-07-20 Thread arun
ruipbarra...@sapo.pt Cc: r-help r-help@r-project.org Sent: Thursday, July 19, 2012 8:17 PM Subject: Re: [R] Subsetting problem data, 2 I'm still getting the message (if this is what you were suggesting I try). The data set I'm using has many more columns other than these variables; could

[R] Subsetting problem data, 2

2012-07-19 Thread Lib Gray
Hello, I didn't give enough information when I sent an query before, so I'm trying again with a more detailed explanation: In this data set, each patient has a different number of measured variables (they represent tumors, so some people had 2 tumors, some had 5, etc). The problem I have is that

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, Try the following. The data is your example of Patient A through E, but from the output of dput(). dat - structure(list(Patient = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L), .Label = c(A, B, C, D, E), class = factor), Cycle = c(1L, 2L, 3L, 4L,

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, I guess so, and I can save you some typing. vars - sort(apply(expand.grid(L, 1:8, 1:2), 1, paste, collapse=)) Then use it and see the result. Rui Barradas Em 20-07-2012 00:00, Lib Gray escreveu: The variables are actually L11, L12, L21, L22, ... , L81, L82. Would just creating a

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, Sorry, forgot about that. It's trickier to write code without a dataset to test it. Try pattern - L[1-8][12] and after the grep print nms to see if it's right. Rui Barradas Em 20-07-2012 00:33, Lib Gray escreveu: I'm getting this error message: