R Under development (unstable) (2026-02-18 r89435 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ### Test code for xtableFtable function > ### David Scott, , 2016-01-14 > library(xtable) > > > tbl <- ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear, row.vars = c(2, 4), + dnn = c("Cylinders", "V/S", "Transmission", "Gears")) > > ## debug(xtableFtable) > xftbl <- xtableFtable(tbl) > str(xftbl) 'xtableFtable' int [1:6, 1:6] 0 0 0 1 2 0 0 0 1 0 ... - attr(*, "row.vars")=List of 2 ..$ V/S : chr [1:2] "0" "1" ..$ Gears: chr [1:3] "3" "4" "5" - attr(*, "col.vars")=List of 2 ..$ Cylinders : chr [1:3] "4" "6" "8" ..$ Transmission: chr [1:2] "0" "1" - attr(*, "ftableAlign")= chr [1:10] "l" "l" "l" "l |" ... - attr(*, "ftableDigits")= num 0 - attr(*, "quote")= logi FALSE - attr(*, "ftableDisplay")= chr [1:10] "s" "s" "s" "s" ... - attr(*, "method")= chr "non.compact" - attr(*, "lsep")= chr " $\\vert$ " - attr(*, "nChars")= num [1:2] 3 4 > unclass(xftbl) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 12 0 [2,] 0 0 0 2 0 0 [3,] 0 1 0 1 0 2 [4,] 1 0 2 0 0 0 [5,] 2 6 2 0 0 0 [6,] 0 1 0 0 0 0 attr(,"row.vars") attr(,"row.vars")$`V/S` [1] "0" "1" attr(,"row.vars")$Gears [1] "3" "4" "5" attr(,"col.vars") attr(,"col.vars")$Cylinders [1] "4" "6" "8" attr(,"col.vars")$Transmission [1] "0" "1" attr(,"ftableAlign") [1] "l" "l" "l" "l |" "r" "r" "r" "r" "r" "r" attr(,"ftableDigits") [1] 0 attr(,"quote") [1] FALSE attr(,"ftableDisplay") [1] "s" "s" "s" "s" "d" "d" "d" "d" "d" "d" attr(,"method") [1] "non.compact" attr(,"lsep") [1] " $\\vert$ " attr(,"nChars") [1] 3 4 > print.xtableFtable(xftbl) % latex table generated in R 4.6.0 by xtable 1.8-8 package % Sun Feb 22 11:26:25 2026 \begin{table}[ht] \centering \begin{tabular}{lll |rrrrrr} \hline & & Cylinders & \multicolumn{1}{l}{ 4} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 6} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 8} & \multicolumn{1}{l}{ } \\ & & Transmission & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} \\ V/S & Gears & & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } \\ \hline 0 & 3 & & 0 & 0 & 0 & 0 & 12 & 0 \\ & 4 & & 0 & 0 & 0 & 2 & 0 & 0 \\ & 5 & & 0 & 1 & 0 & 1 & 0 & 2 \\ 1 & 3 & & 1 & 0 & 2 & 0 & 0 & 0 \\ & 4 & & 2 & 6 & 2 & 0 & 0 & 0 \\ & 5 & & 0 & 1 & 0 & 0 & 0 & 0 \\ \hline \end{tabular} \end{table} > xftbl <- xtableFtable(tbl, method = "row.compact") > print.xtableFtable(xftbl) % latex table generated in R 4.6.0 by xtable 1.8-8 package % Sun Feb 22 11:26:25 2026 \begin{table}[ht] \centering \begin{tabular}{lll |rrrrrr} \hline & & Cylinders & \multicolumn{1}{l}{ 4} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 6} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 8} & \multicolumn{1}{l}{ } \\ V/S & Gears & Transmission & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} \\ \hline 0 & 3 & & 0 & 0 & 0 & 0 & 12 & 0 \\ & 4 & & 0 & 0 & 0 & 2 & 0 & 0 \\ & 5 & & 0 & 1 & 0 & 1 & 0 & 2 \\ 1 & 3 & & 1 & 0 & 2 & 0 & 0 & 0 \\ & 4 & & 2 & 6 & 2 & 0 & 0 & 0 \\ & 5 & & 0 & 1 & 0 & 0 & 0 & 0 \\ \hline \end{tabular} \end{table} > xftbl <- xtableFtable(tbl, method = "col.compact") > print.xtableFtable(xftbl) % latex table generated in R 4.6.0 by xtable 1.8-8 package % Sun Feb 22 11:26:25 2026 \begin{table}[ht] \centering \begin{tabular}{ll |rrrrrr} \hline & Cylinders & \multicolumn{1}{l}{ 4} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 6} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 8} & \multicolumn{1}{l}{ } \\ & Transmission & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} \\ V/S & Gears & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } \\ \hline 0 & 3 & 0 & 0 & 0 & 0 & 12 & 0 \\ & 4 & 0 & 0 & 0 & 2 & 0 & 0 \\ & 5 & 0 & 1 & 0 & 1 & 0 & 2 \\ 1 & 3 & 1 & 0 & 2 & 0 & 0 & 0 \\ & 4 & 2 & 6 & 2 & 0 & 0 & 0 \\ & 5 & 0 & 1 & 0 & 0 & 0 & 0 \\ \hline \end{tabular} \end{table} > xftbl <- xtableFtable(tbl, method = "compact") > print.xtableFtable(xftbl) % latex table generated in R 4.6.0 by xtable 1.8-8 package % Sun Feb 22 11:26:25 2026 \begin{table}[ht] \centering \begin{tabular}{ll |rrrrrr} \hline & Cylinders & \multicolumn{1}{l}{ 4} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 6} & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ 8} & \multicolumn{1}{l}{ } \\ V/S & Gears $\vert$ Transmission & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} \\ \hline 0 & 3 & 0 & 0 & 0 & 0 & 12 & 0 \\ & 4 & 0 & 0 & 0 & 2 & 0 & 0 \\ & 5 & 0 & 1 & 0 & 1 & 0 & 2 \\ 1 & 3 & 1 & 0 & 2 & 0 & 0 & 0 \\ & 4 & 2 & 6 & 2 & 0 & 0 & 0 \\ & 5 & 0 & 1 & 0 & 0 & 0 & 0 \\ \hline \end{tabular} \end{table} > ## debug(print.xtableFtable) > ## undebug(print.xtableFtable) > ## debug(print.xtable) > ## undebug(print.xtable) > > > proc.time() user system elapsed 0.17 0.15 0.28