col_type: Set or retrieve a column type

Description Usage Arguments Details Examples

View source: R/utils.R

Description

Set or retrieve a column type of a colorful data frame

Usage

1
2
3
col_type(x, cols = NULL) <- value

col_type(x, cols = NULL)

Arguments

x

a colorful data frame

cols

column names to set or retrieve

value

character vector with column types

Details

Rather than directly assigning a style to a column (which is possible using the col.styles element) it is preferable to change a style associated with a column type. Several such types are defined in the default styles:

Of course, new column types may be defined and their formatting defined in a theme or a particular data frame style.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mc <- colorDF(mtcars)
col_type(mc, "gear") <- "factor"
col_type(mc, "gear")
col_type(mc) <- list(gear="factor", cyl="integer")
## Note: the *class* of the columns did not change!
## Chaning column type merely changes the way it is displayed
class(mc[["gear"]])

## Hide some columns
col_type(mc, c("disp", "hp")) <- "hidden"

## Create a new type and style
col_type(mc, "carb") <- "carbstyle"
df_style(mc)$type.styles$carbstyle <- list(fg="red", decoration="bold")

colorDF documentation built on Nov. 16, 2020, 9:15 a.m.