format_cells: Add bold, italics, strikethrough in formating to table.

View source: R/NMFSReports.R

format_cellsR Documentation

Add bold, italics, strikethrough in formating to table.

Description

https://stackoverflow.com/questions/28166168/how-to-change-fontface-bold-italics-for-a-cell-in-a-kable-table-in-rmarkdown

Usage

format_cells(dat, rows, cols, fonttype)

Arguments

dat

A data.frame.

rows

The rows you want to apply formatting to.

cols

The columns you want to apply formatting to.

fonttype

fonttype = c("italics", "bold", "strikethrough").

Examples

df <- data.frame(char = c('a','b','c'),
                 num = c(1,2,3))

format_cells(df, 1, 1, "italics")
format_cells(df, 2, 2, "bold")
format_cells(df, 3, 1:2, "strikethrough")

library(knitr)
library(kableExtra)
library(magrittr)
df %>%
  format_cells(1, 1, "italics") %>%
  format_cells(2, 2, "bold") %>%
  format_cells(3, 1:2, "strikethrough") %>%
  knitr::kable()

EmilyMarkowitz-NOAA/NMFSReports documentation built on March 26, 2023, 1:08 a.m.