[R] Ifelse statement on a factor level data frame

Kate Ignatius kate.ignatius at gmail.com
Sun Sep 28 06:49:41 CEST 2014


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 with the code, gives me some kind of variation to it.
Is there some way to get me what I want.  The variable that its
suppose to give back is a bunch of sampleIDs.

Thanks!



More information about the R-help mailing list