inject_div: Inject div

View source: R/utils2.R

inject_divR Documentation

Inject div

Description

Inject an html division tag with style attribute.

Usage

inject_div(x, where, style)

Arguments

x

a matrix or data frame

where

an nx2 matrix of row and column indices or vector (of the form c(row, col, row, col, ...)) specifying which cells to select; if where is missing, style is recycled for all cells

style

vector of character string(s) applied to each cell, recycled if necessary

See Also

htmlTable

Examples

ht <- htmlTable::htmlTable(
  inject_div(head(cars), c(2, 2), style = 'border: dashed 1px;')
)
structure(ht, class = 'htmlTable')

## if where is missing, style is recycled over all cells
ht <- htmlTable::htmlTable(
  inject_div(head(mtcars),
             style = c('color: red;', 'color: blue', 'border: dashed 1px;')
  )
)
structure(ht, class = 'htmlTable')

## where as a matrix
ht <- htmlTable::htmlTable(
  inject_div(head(cars),
             rbind(c(2, 2), c(2, 1), c(5, 2)),
             'background-color: yellow;')
)
structure(ht, class = 'htmlTable')

## where as a vector
ht <- htmlTable::htmlTable(
  inject_div(head(cars),
             c(2,2,2,1,5,2),
             c('background-color: red; color: white;',
               'border: solid 1px;',
               'font-weight: 900; color: blue;')
  )
)
structure(ht, class = 'htmlTable')


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.