dropWhen | R Documentation |
Remove columns from data frames when all rows have specific values
dropWhen(df, unique = FALSE, trash = NULL, requireAll = TRUE, except = NULL)
df |
Data frame to column filter |
unique |
Boolean for whether to return only unique rows after column filtering |
trash |
Character vector containing all the trash values, besides NA, for which a column can be removed |
requireAll |
Boolean as to whether you want to require all rows in a column to equal a value in 'trash' before filtering the column out (TRUE). |
except |
Character vector containing all column names to ignore when dropping columns (these will be retained regardless of the other parameter choices). |
Returns a column filtered data frame. Note, does not take into account numeric, integer or character value differences (it will treat them all the same).
df <- data.frame(this = c(NA, seq(1, 5, 1), seq(1, 5, 1)), that = rep(0, 11), thisotherThing = rep(NA), ohAndThis = rep(c("trashValue", "0"), 11)) cleanerdf <- dropWhen(df, unique = FALSE, trash = c("0", "trashValue"), requireAll = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.