html_matrix {exams.forge}R Documentation

HTML Representation

Description

Creates from a vector, a matrix, an array, or a table, an HTML representation of it. The HTML representation has one column and one row more than the data. The additional row and column are used in order 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, someone 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"
)

html_mx(x, ...)

Arguments

x

vector, matrix, array, table or html_matrix: input.

...

further parameters

byrow

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

numeric

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

integer

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

char

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

logical

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

Returns an html_matrix.

Examples

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

[Package exams.forge version 1.0.10 Index]