gt - gtcars

library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(gt)

gtcars %>%
  dplyr::filter(mfr == "Ferrari", hp < 900) %>%
  dplyr::select(model, hp, mpg_c, mpg_h, msrp) %>%
  gt() %>%
  data_color(
    columns = vars(hp),
    colors = scales::col_numeric(
      palette = c(
        "white", "orange", "red"),
      domain = c(500, 750))
  ) %>%
  data_color(
    columns = vars(mpg_c, mpg_h),
    colors = scales::col_numeric(
      palette = c(
        "white", "green"),
      domain = c(10, 25))
  ) %>%
  data_color(
    columns = vars(msrp),
    colors = scales::col_numeric(
      palette = c(
        "white", "pink", "red"),
      domain = NULL)
  )
Warning: Since gt v0.9.0, the `colors` argument has been deprecated.
• Please use the `fn` argument instead.
This warning is displayed once every 8 hours.
Warning: Since gt v0.3.0, `columns = vars(...)` has been deprecated.
• Please use `columns = c(...)` instead.
Since gt v0.3.0, `columns = vars(...)` has been deprecated.
• Please use `columns = c(...)` instead.
Since gt v0.3.0, `columns = vars(...)` has been deprecated.
• Please use `columns = c(...)` instead.
model hp mpg_c mpg_h msrp
458 Speciale 597 13 17 291744
458 Spider 562 13 17 263553
458 Italia 562 13 17 233509
488 GTB 661 15 22 245400
California 553 16 23 198973
GTC4Lusso 680 12 17 298000
FF 652 11 16 295000
F12Berlinetta 731 11 16 319995

Subscribe

Enjoy this blog? Get notified of new posts by email: