hm_cell: hm_cell

View source: R/html_matrix.R

hm_cellR Documentation

hm_cell

Description

  • hm_cell or hm_index modify a data cell format (fmt="%s"), value (unnamed parameter) or style (text_align="left")

  • hm_col or hm_row modify a row or column format (fmt="%s"), value (unnamed parameter) or style (text_align="left")

Usage

hm_cell(x, row = NULL, col = NULL, ..., byrow = FALSE)

hm_index(x, ind, ...)

hm_title(x, ...)

hm_table(x, ...)

hm_row(x, ind, ...)

hm_col(x, ind, ...)

hm_tr(x, ind, ...)

Arguments

x

html_matrix object

row

integer: row(s) to access

col

integer: column(s) to access

...

elements to change

byrow

logical: order indices by row or column (default: FALSE)

ind

integer vector or matrix: access various (row and columns) elements (first column: row, second column: column)

Value

modified html_matrix object

Examples

l <- html_matrix(matrix(1:6, ncol=2))
# replace l[1,1] by NA
hm_cell(l, 1, 1, NA)
# replace l[1,1] by NA and set the text_align to center
hm_cell(l, 1, 1, NA, text_align="center")
# replace l[1,3] and l[2,1] by NA
rcind <- cbind(c(1,3), c(2, 1))
hm_index(l, rcind, NA)
# set a new title
hm_title(l, "new title")
# set a new row or column title
hm_row(l, 2, "row 2")
hm_col(l, 1, "col 1")
# set fmt by column or row
print(hm_cell(l, fmt=c("%.0f", "%.1f", "%.2f"), byrow=FALSE), which="fmt")
print(hm_cell(l, fmt=c("%.0f", "%.1f"), byrow=TRUE), which="fmt")

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.