[R] How to make sub-headers in R

Boris Steipe boris.steipe at utoronto.ca
Fri May 15 17:42:07 CEST 2015


I don't see that being an option in xtable ... but looking at this:
   http://tex.stackexchange.com/questions/33510/how-do-i-create-the-headings-for-this-multirow-multicolum-table
... it seems to be pretty straightforward to write a function that writes LaTeX output from your dataframe for the Tex multirow package.


B.

On May 15, 2015, at 11:18 AM, Liao, Hongsheng <HLiao at odu.edu> wrote:

> Thanks for your response.  I want to make a LaTeX table with a title and subtitles.  Attached is an example made using Word. I can use "xtable()" and "print()" to generate a LaTeX table of it with "Age" as title.   However, I would like to make the second row "Interval (Inch) ........." as sub-title so that both the title and sub-title can be repeated on every page in my long table split among multiple pages.  In LaTeX, "\endhead" can repeat title but not the row of "Interval ..." because it is not title or sub-title.  I can copy and paste "Interval..." above "\endhead" to get the repetition of "Interval...".  However, I am trying to learn how to avoid "copy and paste", instead, let LaTeX do the job automatically. I know that I am making the question more complicated than my original one and hope it is clear enough this time.
> 
> Hongsheng (Hank) Liao, PhD.
> Lab Manager
> Center for Quantitative  Fisheries Ecology
> Old Dominion University
> 757-683-4571
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.CA.us] 
> Sent: Friday, May 15, 2015 10:43 AM
> To: Liao, Hongsheng; r-help at r-project.org
> Subject: Re: [R] How to make sub-headers in R
> 
> I think you are not interpreting what is happening correctly. Column names are labels used for purposes of referring to the data in your R code. That they might also be useful in presenting data in output is coincidental. The fact that many data input functions replace spaces in those labels with periods should convince you of this fact.
> 
> On the other hand, the options available when you output that table usually depend on where you want to display the result, which you have not mentioned. For example the tables package has many options for labeling columns if you are generating HTML or LaTeX output. Or, you could write your own function to generate any output format you want.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
>                                      Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
> 
> On May 15, 2015 6:55:17 AM PDT, "Liao, Hongsheng" <HLiao at odu.edu> wrote:
>> I know how to make one-row header for a data frame using "colnames". 
>> Is there any function to insert sub-header between the first row of the 
>> data and the header?  Thanks
>> 
>> Hongsheng (Hank) Liao, PhD.
>> Lab Manager
>> Center for Quantitative  Fisheries Ecology Old Dominion University
>> 757-683-4571
>> 
>> 
>> 
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> --
> BEGIN-ANTISPAM-VOTING-LINKS
> ------------------------------------------------------
> 
> Teach CanIt if this mail (ID 03OseHrzs) is spam:
> Spam:        https://www.spamtrap.odu.edu/canit/b.php?i=03OseHrzs&m=a356b01b838f&t=20150515&c=s
> Not spam:    https://www.spamtrap.odu.edu/canit/b.php?i=03OseHrzs&m=a356b01b838f&t=20150515&c=n
> Forget vote: https://www.spamtrap.odu.edu/canit/b.php?i=03OseHrzs&m=a356b01b838f&t=20150515&c=f
> ------------------------------------------------------
> END-ANTISPAM-VOTING-LINKS
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list