Re: [R] Subsetting problem data, 2

2012-07-20 Thread arun
ge - From: Lib Gray To: Rui Barradas Cc: r-help 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 variab

Re: [R] Subsetting problem data, 2

2012-07-20 Thread Chris Campbell
s Chris Campbell Mango Solutions Data Analysis that Delivers http://www.mango-solutions.com +44 (0) 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

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 gr

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 wrote: > Hello, > > I gu

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: nms<-names(data)[grep(vars,names(

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, 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, 2

Re: [R] Subsetting problem data

2012-07-19 Thread Rui Barradas
Hello, Try the following. d <- read.csv(text=" Patient, Cycle, Variable1, Variable2 A, 1, 4, 5 A, 2, 3, 3 A, 3, 4, NA B, 1, 6, 6 B, 2, NA, 6 C, 1, 6, 5 C, 3, 2, 2 ", header=TRUE) d compl <- lapply(split(d, d$Patient), function(x) if(all(diff(x$Cycle) == 1)) x) holes <- lapply(split(d, d$Patie

[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

2012-07-18 Thread arun
l Message - From: Lib Gray To: r-help@r-project.org Cc: Sent: Wednesday, July 18, 2012 3:30 PM Subject: [R] Subsetting problem data Hello, I need to subset my data to only look at the parts that have "holes" in it. I already have a formula to get rid of inconsistencies, but now I nee

Re: [R] Subsetting problem data

2012-07-18 Thread Peter Alspach
Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lib Gray Sent: Thursday, 19 July 2012 7:30 a.m. To: r-help@r-project.org Subject: [R] Subsetting problem data Hello, I need to subset my data to only look at the parts that ha

[R] Subsetting problem data

2012-07-18 Thread Lib Gray
Hello, I need to subset my data to only look at the parts that have "holes" in it. I already have a formula to get rid of inconsistencies, but now I need to look only at the problem data to reconfigure it. In my data set where there are multiple "cycles" per "patient," and I want to highlight the p