Description Usage Arguments Value Examples
For a specified class such as "numeric" or "character", gets the column indexes in a data frame for columns matching the class.
1 | match_col_class(df, class_type)
|
df |
data.frame: data frame for which columns should be matched. |
class_type |
character: type of class to match (e.g. "numeric", "integer", "logical", "character", "factor"). |
integer: the vector of column indexes whose classes match the specified class.
1 2 3 4 5 6 7 8 9 10 11 12 13 | id <- letters[1:3]
size <- c(1.2, 3.5, 4.1)
num <- c(1, 2, 3)
intgr <- c(1L, 2L, 3L)
df_no_fac <- data.frame(id, size, num, intgr, stringsAsFactors = FALSE)
match_col_class(df_no_fac, "character")
df_with_fac <- data.frame(id, size, num, intgr)
match_col_class(df_with_fac, "character")
match_col_class(df_with_fac, "factor")
match_col_class(df_with_fac, "numeric")
match_col_class(df_with_fac, "integer")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.