Learn R Programming

toastui (version 0.4.0)

grid_style_column: Set column style

Description

Apply styles to a column according to CSS properties declared by expression based on data passed to grid..

Usage

grid_style_column(
  grid,
  column,
  background = NULL,
  color = NULL,
  fontWeight = NULL,
  ...
)

Value

A datagrid htmlwidget.

Arguments

grid

A grid created with datagrid().

column

Name of column (variable name) where to apply style.

background

Background color.

color

Text color.

fontWeight

Font weight, you can use "bold" for example.

...

Other CSS properties.

Examples

Run this code

library(toastui)
library(scales)

datagrid(mtcars) %>%
  grid_style_column(
    column = "mpg",
    background = col_numeric("Blues", domain = NULL)(mpg),
    fontWeight = "bold",
    color = ifelse(mpg > 25, "white", "black")
  )

datagrid(mtcars) %>%
  grid_style_column(
    column = "mpg",
    background = col_numeric("Blues", domain = NULL)(mpg),
    fontWeight = "bold",
    color = ifelse(mpg > 25, "white", "black")
  ) %>%
  grid_style_column(
    column = "cyl",
    background = col_bin("Blues", domain = NULL)(cyl),
    fontStyle = "italic"
  )

Run the code above in your browser using DataLab