"HTML.data.frame.min" <- function (x, ...) # minimal (but smaller output) HTML output of a data frame { x <- format(x) x <- as.matrix(x) x[is.na(x)] <- " " x[is.nan(x)] <- " " x[grep("^ *(NA|NaN) *$", x)] <- " " header <- paste("") rowheader <- paste(paste(c('',rep.int('', ncol(x) - 1)), c(as.matrix(colnames(x))), c(rep.int('', ncol(x) - 1),''), sep = ""), collapse="") body <- paste(paste(c('', rep.int('', ncol(x) - 1)), c(t(x)), c(rep.int('', ncol(x) - 1),''), sep = ""), collapse="") trailer <- "" paste(header, rowheader, body, trailer, sep="") } "HTML.individual.row.of.df" <- function (x, ...) # make an HTML table for each row of 'x' { x <- format(x) x <- as.matrix(x) x[is.na(x)] <- " " x[is.nan(x)] <- " " x[grep("^ *(NA|NaN) *$", x)] <- " " header <- paste('"") rowheader <- paste(paste(c('', ncol(x) - 1),''), sep = ""), collapse="") trailer <- '
',rep.int('', ncol(x) - 1)), c(as.matrix(colnames(x))), c(rep.int('
",' paste(paste(c(paste(header,rowheader,''), rep.int('', ncol(x) - 1)), c(t(x)), c(rep.int('', ncol(x) - 1),paste('',trailer)), sep = ""), collapse="") } runjavascript <- function(filename) # loads a javascript file and runs it # must have HTML enabled #cat('&nbsp;<SCRIPT TYPE="text/javascript" DEFER src="data.js"><SCRIPT>')
# this replaces the above line, which doesn't work under IE. # see https://lists.latech.edu/pipermail/javascript/2004-January/006879.html cat(' ', sep="") "jsViaImage" <- function(js) # Runs a javascript snippet by attaching it to an error handler for an image. # HTML must be enabled. # see also: # http://24ways.org/advent/have-your-dom-and-script-it-too # H("img", src = "", alt = "", style = "display:none", onerror = paste(js, ";this.parentNode.removeChild(this);")) "jsViaImage" <- function(js) # Runs a javascript snippet by attaching it to an error handler for an image. # HTML must be enabled. # see also: # http://24ways.org/advent/have-your-dom-and-script-it-too # cat(' H(NULL," ", H("script", type="text/javascript", defer="defer", js))