find_class | R Documentation |
The find_class() extracts variable information having a certain class from an object inheriting data.frame.
find_class(
df,
type = c("numerical", "categorical", "categorical2", "date_categorical",
"date_categorical2"),
index = TRUE
)
df |
a data.frame or objects inheriting from data.frame |
type |
character. Defines a group of classes to be searched. "numerical" searches for "numeric" and "integer" classes, "categorical" searches for "factor" and "ordered" classes. "categorical2" adds "character" class to "categorical". "date_categorical" adds result of "categorical2" and "Date", "POSIXct". "date_categorical2" adds result of "categorical" and "Date", "POSIXct". |
index |
logical. If TRUE is return numeric vector that is variables index. and if FALSE is return character vector that is variables name. default is TRUE. |
character vector or numeric vector. The meaning of vector according to data type is as follows.
character vector : variables name
numeric vector : variables index
get_class
.
# data.frame
find_class(iris, "numerical")
find_class(iris, "numerical", index = FALSE)
find_class(iris, "categorical")
find_class(iris, "categorical", index = FALSE)
# tbl_df
find_class(ggplot2::diamonds, "numerical")
find_class(ggplot2::diamonds, "numerical", index = FALSE)
find_class(ggplot2::diamonds, "categorical")
find_class(ggplot2::diamonds, "categorical", index = FALSE)
# type is "categorical2"
iris2 <- data.frame(iris, char = "chars",
stringsAsFactors = FALSE)
find_class(iris2, "categorical", index = FALSE)
find_class(iris2, "categorical2", index = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.