Search Results

Search found 1 results on 1 pages for 'screechowl'.

Page 1/1 | 1 

  • R how to find NA values after using addNA function

    - by screechOwl
    I have a data frame with a bunch of categorical variables. Some of them contain NA's and I use the addNA function to convert them to an explicit factor level. My problem comes when I try to treat them as NA's they don't seem to register. Here's my example data set and attempts to 'find' NA's: df1 <- data.frame(id = 1:200, y =rbinom(200, 1, .5), var1 = factor(rep(c('abc','def','ghi','jkl'),50))) df1$var2 <- factor(rep(c('ab c','ghi','jkl','def'),50)) df1$var3 <- factor(rep(c('abc','ghi','nop','xyz'),50)) df1[df1$var1 == 'abc','var1'] <- NA df1$var1 <- addNA(df1$var1) df1$isNaCol <- ifelse(df1$var1 == NA, 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(is.na(df1$var1), 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(df1$var1 == 'NA', 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(df1$var1 == '<NA>', 1, 0);summary(df1$isNaCol) Also when I type ??addNA I don't get any matches. Is this a gray-market function or something? Any suggestions would be appreciated.

    Read the article

1