Learn R Programming

clitable (version 0.1.0)

cli_table: generates a text table

Description

generates a text table

Usage

cli_table(
  mat,
  header = TRUE,
  header_style = NULL,
  border_style = "single",
  heatmap_columns = NULL,
  heatmap_colorspace = c("green", "red"),
  hilite_rows = NULL,
  hilite_style = "bgRed",
  NA_style = NULL,
  ...
)

Value

the lines of the text table as an ansi_string vector

Arguments

mat

the table content to print, can be a data.frame or a matrix

header

whether to use the row names as table headers

header_style

the (crayon) style to use to print the headers (cf crayon::style()

border_style

the style to use for the table borders, one of single, double, single-double, double-single, classic

heatmap_columns

the columns that should be displayed as heatmaps, as a vector of column indices, names or logicals

heatmap_colorspace

the colorspace to use for the heatmaps, to be passed to grDevices::colorRamp()

hilite_rows

the rows to highlight, as a vector of column indices, names or logicals

hilite_style

the (crayon) style to use to highlight the rows (cf crayon::style()

NA_style

the (crayon) style to use to highlight the NA values (cf crayon::style()

...

Arguments passed on to scale_numeric

x

the numeric vector to scale

xmin

the minimum value used for the scaling. all all x < xmin are set to 0

xmax

the maximum value used for the scaling. all x > xmax set to 1

Examples

Run this code
  df <- head(datasets::penguins, 20)
  ct <- cli_table(df, header_style = "bold",
    NA_style = "strikethrough",
    heatmap_columns = list("flipper_len"), xmin = 180, xmax = 200,
    hilite_rows = !is.na(df$sex) & df$sex == "female" & df$bill_dep >= 19, 
    hilite_style = "bgGreen"
  )
  cat(ct, sep = "\n")

Run the code above in your browser using DataLab