Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need some pre-processing, extra argument passed to <code>print.xtable</code> and some post-processing:</p> <pre><code>my.table &lt;- data.frame(Specifiers=c("","Spec1", "Spec2", "Spec3"), Values1 = c("N=10", 1.03, 1.71, 2.25), Values2 = c("N=20", 1.32, 1.79, 2.43)) colnames(my.table)[1] &lt;- "" # Pre-processing: rotates column names by 45 degrees head = apply(as.array(names(my.table)), 1, function(x) paste("\\rotatebox{45}{", x, "}")) head = paste(head, c(rep("&amp;", length(head)-1), "\\\\\n"), collapse="") latex.tab &lt;- xtable(my.table, caption=c("Stats")) ltable = print(latex.tab, file="", # File is empty, post-processing needed floating.environment='sidewaystable', include.rownames=FALSE, include.colnames=FALSE, # No colnames booktabs=TRUE, latex.environment="center", # Or NULL # Adds some extra-text after the rows specified in pos. # Adds new \midrule and comments old one. # Adds pre-processed names of columns add.to.row=list(pos=as.list(c(0, 0, 1)), command=as.vector(c(head, "%", "\\midrule\n")))) # Post-processing: replaces \begin{center} with \centering ltable = sub("\\begin{center}\n", "\\centering\n", ltable, fixed=TRUE) ltable = sub("\\end{center}\n", "\n", ltable, fixed=TRUE) # Post-processing: adds alternating colours ltable = sub("\\begin{tabular}", "\\rowcolors{2}{gray!25}{white}\n\\begin{tabular}", ltable, fixed=TRUE) # Writes output to the file cat(ltable, file="Summarystats.tex") </code></pre> <p>If you need other tabs environment than <code>tabular</code> you can 1) add new variable:</p> <pre><code>TABULAR = "tabular" </code></pre> <p>2) Pass it's value to <code>print.xtable</code> like this:</p> <pre><code>... tabular.environment=TABULAR, ... </code></pre> <p>3) Change your post-processing for alternating colors:</p> <pre><code>ltable = sub(sprintf("\\begin{%s}", TABULAR), sprintf("\\rowcolors{2}{gray!25}{white}\n\\begin{%s}", TABULAR), ltable, fixed=TRUE) </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/V9nvU.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload