Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To change the labels for <code>Cohort</code>, change the column and rownames:</p> <pre><code>rownames(Cohort) &lt;- 1:4 colnames(Cohort) &lt;- 5:8 </code></pre> <p>You also add table titles to the <code>xtable</code> call:</p> <pre><code>print(xtable(Cohort, caption = 'My Title'), caption.placement = 'top') </code></pre> <p>You can use <code>caption.placement</code> to tell where to put the caption.</p> <p><strong>EDIT:</strong></p> <p>Based on the comments, I didn't answer the question above. To make <code>xtable</code> print more like <code>table</code> with the labels above the levels, you use <code>add.to.row</code> in the <code>print.xtable</code> function:</p> <pre><code>addtorow &lt;- list() addtorow$pos &lt;- list() addtorow$pos[[1]] &lt;- 0 addtorow$pos[[2]] &lt;- 0 addtorow$command &lt;- c('&amp; &amp; Grade 6 &amp; &amp; \\\\\n', "Grade 3 &amp; A &amp; B &amp; C &amp; D \\\\\n") print(xtable(Cohort, caption = 'My Title'), caption.placement = 'top', add.to.row = addtorow, include.colnames = FALSE) </code></pre> <p><code>add.to.row</code> takes a list with two elements: <code>pos</code> and <code>command</code>. <code>pos</code> is a list of whose length is the same as <code>command</code> which is a vector. Each element of <code>pos</code> is the line in the table where you are placing the corresponding element of <code>command</code>. </p> <p>Here, I want the first two lines to be where the labels go. I set the first and second elements of <code>pos</code> to 0 to indicate that I am putting things on the top of the table. The 0 position is that between the two horizontal rules in the table.</p> <p>The <code>\\\\\n</code> produce the '\\' in the LaTeX code that is used at the end of each line of a table plus a newline character. </p> <p>The help for <code>xtable</code> has a good example of <code>add.to.row</code> for more information. </p>
 

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