utils_as | R Documentation |
Function to quick encode vector or columns to a specific format.
as_numeric()
: Encode columns to numeric using
as.numeric()
.
as_integer()
: Encode columns to integer using
as.integer()
.
as_logical()
: Encode columns to logical using
as.logical()
.
as_character()
: Encode columns to character using
as.character()
.
as_factor()
: Encode columns to factor using
as.factor()
.
as_numeric(.data, ..., .keep = "all", .pull = FALSE) as_integer(.data, ..., .keep = "all", .pull = FALSE) as_logical(.data, ..., .keep = "all", .pull = FALSE) as_character(.data, ..., .keep = "all", .pull = FALSE) as_factor(.data, ..., .keep = "all", .pull = FALSE)
.data |
A data frame or a vector. |
... |
< |
.keep |
Allows you to control which columns from
|
.pull |
Allows you to pull out the last column of the output. It is
useful in combination with |
An object of the same class of .data
with the variables in
...
encoded to the specified format.
Tiago Olivoto tiagoolivoto@gmail.com
library(metan) library(tibble) df <- tibble(y = rnorm(5), x1 = c(1:5), x2 = c(TRUE, TRUE, FALSE, FALSE, FALSE), x3 = letters[1:5], x4 = as.factor(x3)) df # Convert y to integer as_integer(df, y) as_integer(df$y) # convert x3 to factor as_factor(df, x3) # Convert all columns to character as_character(df, everything()) # Convert x2 to numeric and coerce to a vector as_numeric(df, x2, .keep = "used", .pull = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.