formatNA | R Documentation |
Takes a numeric vector and replaces all missing codes with NA and returns a factor if the variable is categorical or a numeric variable if it's numeric.
formatNA(y, type = c("cat", "cont"), codes = c("", "Unk", "N/A"))
y |
a vector. |
type |
whether the variable is |
codes |
vector of missing codes to replace with |
A categorical or numerical vector with all missing formatted as
NA
.
Aline Talhouk, Derek Chiu
y <- c(1:10, "Unk", 12)
formatNA(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.