# NOT RUN {
d <- datasets::iris[, c(5, 1:4)]
colheadings <- c("Species of Iris",
"Sepal length \\\\ (cm)", "Sepal width \\\\ (cm)",
"Petal length \\\\ (cm)", "Petal width \\\\ (cm)")
align <- c("l", "c", "c", "c", "c")
digits <- c(0, 1, 1, 1, 1)
title <- "Measurements of sepal length and width and petal length and width,
for three species of Iris flower."
headnotes <- "\\textbf{Species of Iris}: includes setosa, versicolor, and virginica.
\\textbf{Abbreviations}: cm, centimeters"
levels(d[[1]]) <- sprintf("%s\\footnotemark[%d]", levels(d[[1]]), 1:3)
footnotes <- paste(sprintf("\\footnotemark[%d] Common name is %s iris.", 1:3,
c("Wild Flag", "Blue Flag", "Virginia")), collapse = "\\\\")
hline <- utils::tail(which(!duplicated(d[[1]])), -1) - 1L
PrintTable(d, colheadings, align, digits, title = title, headnotes = headnotes,
footnotes = footnotes, hline = hline, nrec = c(41, 42), rm_dup = 1)
# }
# NOT RUN {
sink("table-example.tex")
cat("\\documentclass{article}",
"\\usepackage[labelsep=period,labelfont=bf]{caption}",
"\\usepackage{booktabs}",
"\\usepackage{makecell}",
"\\usepackage[pdftex]{lscape}",
"\\makeatletter",
"\\setlength{\\@fptop}{0pt}",
"\\makeatother",
"\\begin{document}", sep = "\n")
PrintTable(d, colheadings, align, digits, title = title, headnotes = headnotes,
footnotes = footnotes, hline = hline, nrec = c(41, 42), rm_dup = 1)
cat("\\clearpage\n")
PrintTable(datasets::CO2[, c(2, 3, 1, 4, 5)], digits = c(0, 0, 0, 0, 1),
title = "Carbon dioxide uptake in grass plants.", nrec = 45, rm_dup = 3)
cat("\\clearpage\n")
PrintTable(datasets::mtcars, title = "Motor trend car road tests.",
landscape = TRUE, include.rownames = TRUE)
cat("\\end{document}\n")
sink()
tools::texi2pdf("table-example.tex", clean = TRUE) # requires TeX installation
system("open table-example.pdf")
file.remove("table-example.tex", "table-example.pdf")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab