| replacevar | R Documentation |
Replaces values in an explicit data frame or the active R4VN data frame.
replacevar(..., data = NULL)
... |
In active mode: |
data |
Optional explicit data frame object. |
missing(x) may be used inside conditions. Use . as a missing replacement.
The edited data frame invisibly.
d <- data.frame(age = c(8, 15, 200, NA_real_))
usedf(d, quiet = TRUE)
replacevar(age, ., age > 120)
replacevar(age, 99, missing(age))
# Extended usage examples
d <- data.frame(age = c(8, 15, 200, NA_real_),
sex = factor(c("M", "F", "M", "F")))
usedf(d, quiet = TRUE)
# Replace an impossible value by missing
replacevar(age, ., age > 120)
# Replace missing values
replacevar(age, 99, missing(age))
# Replace a factor value under a condition
replacevar(sex, "Female", sex == "F")
# Explicit-data syntax
replacevar(d, age, ., age > 120)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.