dummy2

Format

An object of class NULL of length 0.

Details

The following function turns an R data frame into the correct format. 
It ignores column and row names, but should get you started.

tabular <- function(df, ...) {
stopifnot(is.data.frame(df))

align <- function(x) if (is.numeric(x)) "r" else "l"
col_align <- vapply(df, align, character(1))

cols <- lapply(df, format, ...)
contents <- do.call("paste",
 c(cols, list(sep = " \tab ", collapse = "\cr\n  ")))

paste("\tabular{", paste(col_align, collapse = ""), "}{\n  ",
 contents, "\n}\n", sep = "")
}

cat(tabular(mtcars[1:5, 1:5]))
21.061601103.90
21.061601103.90
22.84108933.85
21.462581103.08
18.783601753.15