Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Patrick Burns
I believe you are in Circle 8.2.7 of The R Inferno. http://www.burns-stat.com/documents/books/the-r-inferno/ Pat On 28/09/2014 05:49, Kate Ignatius wrote: Quick question: I am running the following code on some variables that are factors: dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) ==

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Kate Ignatius
Strange that, I did put everything with as.character but all I got was the same... class of dbpmn[,2]) = factor class of dbpmn[,21] = factor class of dbpmn[,20] = data.frame This has to be a problem ??? I can put reproducible output here but not sure if this going to of help here. I think

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Bert Gunter
Inline. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Sun, Sep 28, 2014 at 6:38 AM, Kate Ignatius kate.ignat...@gmail.com wrote: Strange that, I did put

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread Kate Ignatius
Apologies - you're right. Missed it in the pdf. K. On Sun, Sep 28, 2014 at 10:22 AM, Bert Gunter gunter.ber...@gene.com wrote: Inline. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not

Re: [R] Ifelse statement on a factor level data frame

2014-09-28 Thread William Dunlap
ifelse() often has problems constructing the right type of return value. if you want to keep the data as a factor (with its existing levels) use x[condition] - value instead of ifelse(condition, value, x). E.g., x - factor(c(Large,Small,Small,XLarge), levels=c(Small,Med,Large,XLarge)) x

[R] Ifelse statement on a factor level data frame

2014-09-27 Thread Kate Ignatius
Quick question: I am running the following code on some variables that are factors: dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) == as.character(dbpmn[,(21)]), dbpmn[,20], '') Instead of returning some value it gives me this: c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) Playing around

Re: [R] Ifelse statement on a factor level data frame

2014-09-27 Thread Jeff Newmiller
Not reproducible, ball in your court. However, in the meantime, my suggestion is to not do that. Convert to character before you alter the factor, then convert back when you are done. --- Jeff Newmiller

Re: [R] Ifelse statement on a factor level data frame

2014-09-27 Thread Jim Lemon
On Sun, 28 Sep 2014 12:49:41 AM Kate Ignatius wrote: Quick question: I am running the following code on some variables that are factors: dbpmn$IID1new - ifelse(as.character(dbpmn[,2]) == as.character(dbpmn[,(21)]), dbpmn[,20], '') Instead of returning some value it gives me this: