Drop undefined values in a data frame
drop_undefined.Rd
This function drops undefined values in a data frame by replacing them with NA.
Usage
drop_undefined(df, vars, vals_undefined = c("pnta", "dnk"), suffix = NULL)
Value
The modified data frame with undefined values replaced by NA. If suffix is NULL or an empty string, variables vars are modified; otherwise, new variables are added with suffix.
Examples
# Create a sample data frame
df <- data.table::data.frame(x = c("a", "b", "pnta", "dnk", "e"), y = c("a", "b", "c", "d", "e"))
#> Error: 'data.frame' is not an exported object from 'namespace:data.table'
# Define variables and undefined values
vars <- c("x", "y")
vals_undefined <- c("pnta", "dnk")
# Drop undefined values
result <- drop_undefined(df, vars, vals_undefined)
#> Error in drop_undefined(df, vars, vals_undefined): Assertion on 'df' failed: Must be of type 'data.frame', not 'closure'.
print(result)
#> Error: object 'result' not found