| coerce_numeric_vars | R Documentation |
For each specified column, attempts to coerce the values to numeric.
Values that cannot be coerced (e.g. character strings such as
"hemolysed" appearing in an otherwise numeric column) are replaced
with NA. A message lists the dropped values per column so the user
is aware of what was discarded. Use suppressMessages() to silence.
coerce_numeric_vars(data, ...)
data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). |
... |
< |
Columns that are already numeric are left untouched.
data with the specified columns coerced to numeric.
df <- data.frame(x = c("1", "2", "hemolysed", "3"),
y = c("a", "b", "c", "d"))
coerce_numeric_vars(df, x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.