Stefan Petersson
2010-Jan-26 11:21 UTC
[R] Formatting cgroup and factor level labels in Hmisc latex function
I'm trying to typeset at simple crosstable with the Hmisc latex function. And I have two problems. 1. How do I make all columns the same width? The Latex function seems very unwilling to break the 'cgroup' labels and the factor level labels. Please have look at this screenshot that shows my problem: >> http://hem.passagen.se/stpe9096/table.png So, how can I make sure that the cgroup labels and the factor level labels are sufficiently line breaked and/or hyphenated to make the columns evenly spaced? 2. Is there something like a 'widetable' package that can break a wide table into several tables with repeated 'rgroup' labels? As You can see in the screenshot, the table runs way off the page. And I know that there is a 'longtable' package that can do exactly this, but for tables with long rgroup lists.
Ista Zahn
2010-Jan-26 14:46 UTC
[R] Formatting cgroup and factor level labels in Hmisc latex function
Hi Stefan, See comments in line below. On Tue, Jan 26, 2010 at 6:21 AM, Stefan Petersson <stefan.petersson at inizio.se> wrote:> > I'm trying to typeset at simple crosstable with the Hmisc latex function. And I have two problems. > > 1. How do I make all columns the same width?Use cgroup.just="p{<width><unit>} For example, for column groups 2 inches wide, use cgroup.just="p{2in}" The Latex function seems very unwilling to break the 'cgroup' labels and the factor level labels. Please have look at this screenshot that shows my problem: The latex() function will do whatever you tell it to...> > ?>> http://hem.passagen.se/stpe9096/table.png > > So, how can I make sure that the cgroup labels and the factor level labels are sufficiently line breaked and/or hyphenated to make the columns evenly spaced? > > 2. Is there something like a 'widetable' package that can break a wide table into several tables with repeated 'rgroup' labels? As You can see in the screenshot, the table runs way off the page. And I know that there is a 'longtable' package that can do exactly this, but for tables with long rgroup lists.I would stick with long table. Use R to re-organize you data so that it is long instead of wide, and use longtable. HTH, Ista> > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
Dieter Menne
2010-Jan-26 18:54 UTC
[R] Formatting cgroup and factor level labels in Hmisc latex function
stefan.petersson wrote:> > > I'm trying to typeset at simple crosstable with the Hmisc latex function. > And I have two problems. > > 1. How do I make all columns the same width? The Latex function seems very > unwilling to break the 'cgroup' labels and the factor level labels. Please > have look at this screenshot that shows my problem: > > >> http://hem.passagen.se/stpe9096/table.png > > So, how can I make sure that the cgroup labels and the factor level labels > are sufficiently line breaked and/or hyphenated to make the columns evenly > spaced? > >To force a fixed width, use a custom latex column format and pass it to the latex function. If this does not solve the column break problem, manually pass the column titles and insert a "\n". I have used the first version, the second one might not work. stefan.petersson wrote:> > > 2. Is there something like a 'widetable' package that can break a wide > table into several tables with repeated 'rgroup' labels? As You can see in > the screenshot, the table runs way off the page. And I know that there is > a 'longtable' package that can do exactly this, but for tables with long > rgroup lists. > >A workaround is to rotate the output with latex, or to use a smaller font. Also, making the padding space columns in latex smaller can help. Dieter -- View this message in context: http://n4.nabble.com/Formatting-cgroup-and-factor-level-labels-in-Hmisc-latex-function-tp1290232p1310696.html Sent from the R help mailing list archive at Nabble.com.
Dieter Menne
2010-Jan-26 19:05 UTC
[R] Formatting cgroup and factor level labels in Hmisc latex function
stefan.petersson wrote:> > > I'm trying to typeset at simple crosstable with the Hmisc latex function. > And I have two problems. > > 1. How do I make all columns the same width? The Latex function seems very > unwilling to break the 'cgroup' labels and the factor level labels. Please > have look at this screenshot that shows my problem: > >Snippets for custom width \newcolumntype{R}[1]{>{\raggedright\hspace{0pt}\arraybackslash}p{#1}} <<databasefields,results=tex>>col.just = c("l","l","R{9cm}") # You can use past to construct the width be code latex(... col.just=col.just, Dieter -- View this message in context: http://n4.nabble.com/Formatting-cgroup-and-factor-level-labels-in-Hmisc-latex-function-tp1290232p1310708.html Sent from the R help mailing list archive at Nabble.com.