col_type<- {colorDF} | R Documentation |
Set or retrieve a column type
Description
Set or retrieve a column type of a colorful data frame
Usage
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:
character
numeric
integer
factor
identifier
pval
match
hidden
default
Of course, new column types may be defined and their formatting defined in a theme or a particular data frame style.
Examples
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")
[Package colorDF version 0.1.7 Index]