data.frame.to.html.table.string: Output the contents of a numeric matrix or dataframe into...

View source: R/data.frame.to.html.table.string.R

data.frame.to.html.table.stringR Documentation

Output the contents of a numeric matrix or dataframe into html table notation string

Description

Output the contents of a numeric matrix or dataframe into html table notation string

Usage

data.frame.to.html.table.string(
  dframe,
  class = NA,
  topLeft = "",
  cellFormat = function(i, j, cell, dataFrame) {
     if (i == 0) {
         tmp <-
    paste("<th>", cell, "</th>", sep = "")
     }
     else {
         tmp <-
    paste("<td>", cell, "</td>", sep = "")
     }
     return(tmp)
 }
)

Arguments

dframe

A data.frame or matrix

topLeft

A string that will fill the top left corner (first cell of the first row) of the table

cellFormat

A function that will convert the cell content to a latex compatible string. The function has to accept three arguments, row, column, cell and a dataFrame variable and has to return a string. It is applied to the cells (i,j > 0) and to the margins (i,j = 0) including topLeft which sits at (0,0). The cell value is the value of the cell, the dataFrame variable allows to see if the entry is the maximum in the row etc.

header

A boolean toggle. If true a full latex table with begintable etc is created, if false only cells are converted.

Value

A vector of strings where each entry is one line of html code.

Examples

n <- 3
m <- 6
M1 <- matrix(1:(n*m),n,m)
rownames(M1) <- 1:n
colnames(M1) <- 1:m
S1 <- data.frame.to.html.table.string(M1,topLeft="TL")

KlausHerrmann/khermisc documentation built on May 6, 2023, 7:08 p.m.