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]) ==
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
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
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
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
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
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
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:
8 matches
Mail list logo