Hi, 

I expect this is simple but haven’t found an answer looking on the
archives...

 

I want to convert ‘NA’ (missing) to particular levels (nonmissing) in factor
vectors.

 

e.g. I know

> X <- c(1, 2, 3)

> summary(X)

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 

    1.0     1.5     2.0     2.0     2.5     3.0 

> X <- as.factor(X)

> summary(X)

1 2 3 

1 1 1 

> levels(X)

[1] "1" "2" "3"

> levels(X) <- c("A", NA, "B")

> summary(X)

   A    B NA's 

   1    1    1

 

But what if I want to turn the NA back into a level? 

How do I do this?

 

Thanks,  Jon

 

 


-- 

Checked by AVG Free Edition.

17:40
 

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to