Learn R Programming

exams.forge (version 1.0.11)

zebra: Apply Zebra Striping to an HTML Matrix

Description

This function applies alternating background colors (zebra striping) to an html_matrix object, either by rows or by columns.

Usage

zebra(x, col = c("#FFFFFF", "#CCCCCC"), byrow = TRUE)

Value

An html_matrix object with updated background colors.

Arguments

x

An html_matrix object to which the zebra striping will be applied.

col

A character vector of colors to use for striping. Defaults to c("#FFFFFF", "#CCCCCC").

byrow

Logical; if TRUE, colors are applied to rows, otherwise to columns. Default is TRUE.

Examples

Run this code
library("magrittr")
m  <- matrix(1:12, ncol = 4)
hm <- html_matrix(m) %>% zebra()
html <- toHTML(hm, browser = TRUE)

Run the code above in your browser using DataLab