html_matrix {HKRbook}R Documentation

html_matrix

Description

Creates from a vector, matrix, array, or table a HTML representation of it. The HTML representation has one column and row more than the data. The additional row and column are used to have a title (top left), the column names (top), and the row names (left).

You can set the style attributes (⁠<td style="...">⁠) via hm_cell, hm_title, hm_col, and hm_row. For example: hm_cell(hm, 1, 1, text_align="right") will lead to (⁠<td style="text-align:right;">⁠) for the cell (1,1) and any unnamed element will change the cell value. Note: since - is an operator in R, we use ⁠_⁠ instead. Of course, you could use "text-align"="right", but I'am lazy.

Usage

html_matrix(x, ...)

## Default S3 method:
html_matrix(
  x,
  ...,
  byrow = FALSE,
  numeric = list(text_align = "right"),
  integer = list(text_align = "right"),
  char = list(text_align = "left"),
  logical = list(text_align = "right"),
  border = "#999999"
)

Arguments

x

vector, matrix, array, table or html_matrix: input

...

further parameters

byrow

logical: create a row or column matrix if x is one-dimensional (default: FALSE)

numeric

list: list of HTML style properties for a cell if class(x[i,j])=="numeric" (default: list(text_align="right"))

integer

list: list of HTML style properties for a cell if class(x[i,j])=="integer" (default: list(text_align="right"))

char

list: list of HTML style properties for a cell if class(x[i,j])=="character" (default: list(text_align="left"))

logical

list: list of HTML style properties for a cell if class(x[i,j])=="logical" (default: list(text_align="right"))

border

character: vector of background color for a border cell (default: "#999999"))

Value

html_matrix returns a html_matrix, print returns invisible a character matrix

Examples

m <- matrix(1:6, ncol=2)
m
l <- html_matrix(m)
l

[Package HKRbook version 0.1.3 Index]