Re: [R] Problematic If-Else statement

2011-09-16 Thread MacQueen, Don
It's probably not a sensible thing to do, but I'm going to guess. With a name like "days_to_tumor_recurrence", I might expect numeric (integer) values. But "null" and numeric don't mix. as.numeric(c('24','null',23')) will return 24, NA, 23. There may have been such a conversion in the preparatio

Re: [R] Problematic If-Else statement

2011-09-16 Thread David Winsemius
On Sep 16, 2011, at 11:49 AM, Ben Ganzfried wrote: > Thanks David. That works perfectly! Although, I'm still not sure I > understand entirely why the input file says the character value > "null" and yet, it actually is NA... Unless you show us the file as it would appear in a text editor, a

Re: [R] Problematic If-Else statement

2011-09-16 Thread Ben Ganzfried
Thanks David. That works perfectly! Although, I'm still not sure I understand entirely why the input file says the character value "null" and yet, it actually is NA... On Fri, Sep 16, 2011 at 11:35 AM, David Winsemius wrote: > > On Sep 16, 2011, at 11:08 AM, David Winsemius wrote: > > >> On Sep

Re: [R] Problematic If-Else statement

2011-09-16 Thread David Winsemius
On Sep 16, 2011, at 11:08 AM, David Winsemius wrote: On Sep 16, 2011, at 10:36 AM, Ben Ganzfried wrote: Hi guys, snipped Second, I changed the first line of my code to: tmp <- ifelse(uncurated $days_to_tumor_recurrence==NA,"norecurrence","recurrence") I do not know why your original d

Re: [R] Problematic If-Else statement

2011-09-16 Thread David Winsemius
On Sep 16, 2011, at 10:36 AM, Ben Ganzfried wrote: Hi guys, My code (next 2 lines below) isn't doing what I'm expecting it to: tmp <- ifelse(uncurated $days_to_tumor_recurrence=="null","norecurrence","recurrence") curated$recurrence_status <- tmp I want the column "recurrence_status" in my

Re: [R] Problematic If-Else statement

2011-09-16 Thread R. Michael Weylandt
It seems that your original data has NA values in it (which you should have said in your original post) and that's where they are coming from in tmp. E.g., R> NA == "null" [1] NA To identify them, you need to use is.na() rather than "==NA" E.g., tmp[is.na(tmp)] <- "norecurrence" and similarly

Re: [R] Problematic If-Else statement

2011-09-16 Thread Ben Ganzfried
Hi Michael, I mean the character string "null". Thanks, Ben On Fri, Sep 16, 2011 at 10:40 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > Do you actually mean the character string "null" or do you mean the NULL it > doesn't exist thing? If that's the case, you need to write is.n

Re: [R] Problematic If-Else statement

2011-09-16 Thread R. Michael Weylandt
Do you actually mean the character string "null" or do you mean the NULL it doesn't exist thing? If that's the case, you need to write is.null(), something like is.NA()... Michael Weylandt On Fri, Sep 16, 2011 at 10:36 AM, Ben Ganzfried wrote: > Hi guys, > > My code (next 2 lines below) isn't do