h_df_factors_with_explicit_na | R Documentation |
data.frame
This helper function converts all character and logical variables
to factor variables in a data.frame
. It also sets an explicit missing data level
for all factor variables that have at least one NA
. Empty strings are handled
as NA
.
h_df_factors_with_explicit_na(data, na_level = "<Missing>")
data |
( |
na_level |
( |
The modified data.
dat <- data.frame( a = c(NA, 2), b = c("A", NA), c = c("C", "D"), d = factor(c(NA, "X")), e = factor(c("Y", "Z")) ) h_df_factors_with_explicit_na(dat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.