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"
Apologies - you're right. Missed it in the pdf.
K.
On Sun, Sep 28, 2014 at 10:22 AM, Bert Gunter wrote:
> Inline.
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> Cliffo
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 wrote:
> Strange that,
>
> I did put everything with as.charact
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 its
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]) ==
as
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
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
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 wi
8 matches
Mail list logo