[R] How to make sub-headers in R

Bert Gunter gunter.berton at gene.com
Fri May 15 16:48:51 CEST 2015


1. No.

2. You would do well to go through an R tutorial -- the "Introduction
to R" ships with R, but there are many more on the Web --  as you
appear to be applying spreadsheet type concepts to R's data.frame data
structure. While there certainly is a resemblance, conflating the two
is a grave error that will get you into a lot of trouble. If you wish
to use R, learn R; don't intuit or presume.

3. One way to simulate what you want to do is to attach a "subhead"
attribute to your data frame, class this structure( e.g.
c("frame_with_subhead","data.frame") ) and write a (S3)
print.frame_with_subhead method to print objects of the class in some
suitable way. See ?attributes, ?attr, and ?UseMethod. However, all
these man pages will be terse and assume that you have done the
aforementioned homework of learning R. You could, of course, use S4
classes or any other OO system available for R instead of S3.



Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll

On Fri, May 15, 2015 at 6:55 AM, 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.

More information about the R-help mailing list