Make a dataframe colorful

colorDF(x, theme = NULL)

as.colorDF(x, ...)

Arguments

x

a data frame or similar object, e.g. tibble, data.table or any object for which as.data.frame call returns a data frame

theme

Which theme to use

...

further arguments are passed to colorDF().

Value

a colorful data frame – identical object but with the .style

attribute set and class "colorDF" added.

Details

These functions turn any data frame like object (i.e. object which inherits the data.frame class, such as a tibble or a data table).

Apart from adding the S3 class "colorDF", the .style attribute (and later the .coltp attribute), the only thing that really changes is the print method (see print_colorDF()). In other words, the behavior of the object does not change (e.g., a base::data.frame() will by the default drop dimensions if one column is selected, while a tibble::tibble() will not). colorDF is just for visualization, never truly manipulation.

Several color themes come with the package; see colorDF_themes_show(). When creating a colorful data frame, a theme might be directly selected; otherwise the getOption("colorDF_theme") is consulted and if NULL, a default theme will be selected. The theme associated with an object becomes a style and can be further manipulated (see df_style()).

as.colorDF() calls colorDF(); this function is only here for completeness.

See also

Introduction to the package; df_style() on how to modify style of the colorful data frame; col_type() on how to change column types; colorDF_themes() to list all themes; colorDF_themes_show() to view all themes.

Examples

colorDF(mtcars)
#> # Color data frame (class colorDF) 11 x 32:
#> # (Showing rows 1 - 20 out of 32)
#>                    │mpg  │cyl  │disp │hp   │drat │wt   │qsec │vs   │am   │gear 
#>           Mazda RX4│   21│    6│  160│  110│  3.9│  2.6│   16│    0│    1│    4
#>       Mazda RX4 Wag│   21│    6│  160│  110│  3.9│  2.9│   17│    0│    1│    4
#>          Datsun 710│   23│    4│  108│   93│  3.9│  2.3│   19│    1│    1│    4
#>      Hornet 4 Drive│   21│    6│  258│  110│  3.1│  3.2│   19│    1│    0│    3
#>   Hornet Sportabout│   19│    8│  360│  175│  3.1│  3.4│   17│    0│    0│    3
#>             Valiant│   18│    6│  225│  105│  2.8│  3.5│   20│    1│    0│    3
#>          Duster 360│   14│    8│  360│  245│  3.2│  3.6│   16│    0│    0│    3
#>           Merc 240D│   24│    4│  147│   62│  3.7│  3.2│   20│    1│    0│    4
#>            Merc 230│   23│    4│  141│   95│  3.9│  3.1│   23│    1│    0│    4
#>            Merc 280│   19│    6│  168│  123│  3.9│  3.4│   18│    1│    0│    4
#>           Merc 280C│   18│    6│  168│  123│  3.9│  3.4│   19│    1│    0│    4
#>          Merc 450SE│   16│    8│  276│  180│  3.1│  4.1│   17│    0│    0│    3
#>          Merc 450SL│   17│    8│  276│  180│  3.1│  3.7│   18│    0│    0│    3
#>         Merc 450SLC│   15│    8│  276│  180│  3.1│  3.8│   18│    0│    0│    3
#>  Cadillac Fleetwood│   10│    8│  472│  205│  2.9│  5.2│   18│    0│    0│    3
#> Lincoln Continental│   10│    8│  460│  215│  3.0│  5.4│   18│    0│    0│    3
#>   Chrysler Imperial│   15│    8│  440│  230│  3.2│  5.3│   17│    0│    0│    3
#>            Fiat 128│   32│    4│   79│   66│  4.1│  2.2│   19│    1│    1│    4
#>         Honda Civic│   30│    4│   76│   52│  4.9│  1.6│   19│    1│    1│    4
#>      Toyota Corolla│   34│    4│   71│   65│  4.2│  1.8│   20│    1│    1│    4
#>                    │carb 
#>           Mazda RX4│    4
#>       Mazda RX4 Wag│    4
#>          Datsun 710│    1
#>      Hornet 4 Drive│    1
#>   Hornet Sportabout│    2
#>             Valiant│    1
#>          Duster 360│    4
#>           Merc 240D│    2
#>            Merc 230│    2
#>            Merc 280│    4
#>           Merc 280C│    4
#>          Merc 450SE│    3
#>          Merc 450SL│    3
#>         Merc 450SLC│    3
#>  Cadillac Fleetwood│    4
#> Lincoln Continental│    4
#>   Chrysler Imperial│    4
#>            Fiat 128│    1
#>         Honda Civic│    2
#>      Toyota Corolla│    1
colorDF(mtcars, theme="bw")
#> # Color data frame (class colorDF) 11 x 32:
#> # (Showing rows 1 - 20 out of 32)
#>                    │mpg  │cyl  │disp │hp   │drat │wt   │qsec │vs   │am   │gear 
#>           Mazda RX4│   21│    6│  160│  110│  3.9│  2.6│   16│    0│    1│    4
#>       Mazda RX4 Wag│   21│    6│  160│  110│  3.9│  2.9│   17│    0│    1│    4
#>          Datsun 710│   23│    4│  108│   93│  3.9│  2.3│   19│    1│    1│    4
#>      Hornet 4 Drive│   21│    6│  258│  110│  3.1│  3.2│   19│    1│    0│    3
#>   Hornet Sportabout│   19│    8│  360│  175│  3.1│  3.4│   17│    0│    0│    3
#>             Valiant│   18│    6│  225│  105│  2.8│  3.5│   20│    1│    0│    3
#>          Duster 360│   14│    8│  360│  245│  3.2│  3.6│   16│    0│    0│    3
#>           Merc 240D│   24│    4│  147│   62│  3.7│  3.2│   20│    1│    0│    4
#>            Merc 230│   23│    4│  141│   95│  3.9│  3.1│   23│    1│    0│    4
#>            Merc 280│   19│    6│  168│  123│  3.9│  3.4│   18│    1│    0│    4
#>           Merc 280C│   18│    6│  168│  123│  3.9│  3.4│   19│    1│    0│    4
#>          Merc 450SE│   16│    8│  276│  180│  3.1│  4.1│   17│    0│    0│    3
#>          Merc 450SL│   17│    8│  276│  180│  3.1│  3.7│   18│    0│    0│    3
#>         Merc 450SLC│   15│    8│  276│  180│  3.1│  3.8│   18│    0│    0│    3
#>  Cadillac Fleetwood│   10│    8│  472│  205│  2.9│  5.2│   18│    0│    0│    3
#> Lincoln Continental│   10│    8│  460│  215│  3.0│  5.4│   18│    0│    0│    3
#>   Chrysler Imperial│   15│    8│  440│  230│  3.2│  5.3│   17│    0│    0│    3
#>            Fiat 128│   32│    4│   79│   66│  4.1│  2.2│   19│    1│    1│    4
#>         Honda Civic│   30│    4│   76│   52│  4.9│  1.6│   19│    1│    1│    4
#>      Toyota Corolla│   34│    4│   71│   65│  4.2│  1.8│   20│    1│    1│    4
#>                    │carb 
#>           Mazda RX4│    4
#>       Mazda RX4 Wag│    4
#>          Datsun 710│    1
#>      Hornet 4 Drive│    1
#>   Hornet Sportabout│    2
#>             Valiant│    1
#>          Duster 360│    4
#>           Merc 240D│    2
#>            Merc 230│    2
#>            Merc 280│    4
#>           Merc 280C│    4
#>          Merc 450SE│    3
#>          Merc 450SL│    3
#>         Merc 450SLC│    3
#>  Cadillac Fleetwood│    4
#> Lincoln Continental│    4
#>   Chrysler Imperial│    4
#>            Fiat 128│    1
#>         Honda Civic│    2
#>      Toyota Corolla│    1