| dropvar | R Documentation |
Drops variables or observations from an explicit data frame or active data.
dropvar(..., data = NULL, obs = NULL)
... |
Variable selectors. For backward compatibility, an explicit data frame may be the first unnamed argument. |
data |
Optional explicit data frame object. |
obs |
Optional observations to drop. |
The edited data frame invisibly.
d <- data.frame(id = 1:4, age = c(10, 20, NA, 40), note_kt = letters[1:4])
usedf(d, quiet = TRUE)
dropvar("*_kt")
dropvar(obs = age < 18)
# Extended usage examples
d <- data.frame(id = 1:5, age = c(10, 20, NA, 40, 50),
temp_a = 1:5, temp_b = 6:10, note = letters[1:5])
# Drop one or more variables
d1 <- d; dropvar(d1, note)
d2 <- d; dropvar(d2, temp_a, temp_b)
# Drop variables with a wildcard
d3 <- d; dropvar(d3, "temp_*")
# Drop observations satisfying a condition
d4 <- d; dropvar(d4, obs = age < 18)
d5 <- d; dropvar(d5, obs = missing(age))
# Drop variables and observations together
d6 <- d; dropvar(d6, note, obs = age < 18)
# Active-data syntax
usedf(d, quiet = TRUE); dropvar("temp_*"); dropvar(obs = missing(age))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.