html_table <- function(headings, nrows){ ncols <- length(headings) pad_table <- function(s, char2="d"){ pad <- paste0("", s, "", collapse="") paste0("", pad, "", collapse="") } theader <- pad_table(c("", headings), char2="h") gen_row <- function(n) c(n, sample(9999, ncols)) tbody <- lapply(1:nrows, gen_row) |> sapply(pad_table) cat("", theader, sep="\n") writeLines(tbody) cat("
\n") } html_table(c("X", "Y", "Z"), 3)