replace_na | R Documentation |
Replace NAs with specified values
replace_na(.x, replace)
.x |
A data.frame/data.table or a vector |
replace |
If |
df <- data.table(
x = c(1, 2, NA),
y = c(NA, 1, 2)
)
# Using replace_na() inside mutate()
df %>%
mutate(x = replace_na(x, 5))
# Using replace_na() on a data frame
df %>%
replace_na(list(x = 5, y = 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.