print.colorDF {colorDF}R Documentation

Print method for colorful data frames


This is the core of the colorDF package – a print method for the colorful (and other) data frames.


## S3 method for class 'colorDF'
print(x, ...)

  n = getOption("colorDF_n"),
  width = getOption("width"),
  row.names = TRUE,
  tibble_style = getOption("colorDF_tibble_style"),
  highlight = NULL,
  sep = getOption("colorDF_sep"),
  bg = NULL,
  fg = NULL,



a colorful data frame (object with class colorDF), a data.frame, a tibble, a data.table or any other object which can be coerced to data frame with function.


further arguments are ignored


Number of rows to show (default=20, use Inf to show all; this value can be set with options("colorDF_n"))


number of characters that the data frame should span on output


if TRUE (default), row names will be shown on output


whether to print with tibble style (overrides style setting)


a logical vector indicating which rows to highlight


column separator string (overrides style setting)


set default background for the table


set default foreground for the table


print_colorDF is the exported function, print.colorDF is the S3 method. Otherwise they are identical.

print_colorDF is a function that can be applied to any data frame like object. Using colorDF() to change the class of the object is only necessary if modifications to the style are required, such as specifying column type. However, print_colorDF applied to virtually any data frame, tibble or data table will work. In such a case, the theme used to display the data frame will either be taken from getOption("colorDF_theme") or a default theme will be used.

Column types

Column types are basically the column classes (numeric, factor etc.) plus a few specialized types (such as p-value) which are displayed slightly differently. For example, an identifier will usually be shown in bold, and significant p-values will be red (details depend on the given theme and style; see col_type() and df_style() for more information).

Changing the default methods

It is possible to assign print_colorDF to the default methods, thus changing the way how tibbles, data frames or other data frame like objects are displayed. This should be generally safe, but use it on your own peril and preferably only in interactive sessions. I use the following code in my .Rprofile file:

if(interactive()) { <- colorDF::print_colorDF
  print.tbl        <- colorDF::print_colorDF <- colorDF::print_colorDF

See Also

df_style() on how to modify colorful data frames styles; col_type() on how to change the column types; colorDF_themes_show() to demonstrate available themes; highlight() and df_search() functions on how to use colorDF to highlight selected parts of a data frame.


print_colorDF(mtcars, row.names=FALSE)

if(require(dplyr)) {
    starwars %>% colorDF
    starwars %>% print_colorDF(highlight=.$homeworld == "Tatooine")

    ## equivalently
    starwars %>% highlight(.$homeworld == "Tatooine")

    ## with another style
    starwars %>% print_colorDF(tibble_style=TRUE, sep=" |%%| ")

[Package colorDF version 0.1.4 Index]