Re: [R] Hmisc latex: table column width

From: Lauri Nikkinen <lauri.nikkinen_at_iki.fi>
Date: Mon, 07 Jul 2008 11:12:03 +0300

Frank Harrell gave me a hint:

http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf

but I'm still puzzled. Now I do know how to modify e.g cell colors in a table (see below) but I still know how to modify the width parameter of the column. Can anyone give a helping hand?

Thanks,
Lauri

####### R code #########

DF <- data.frame(Titanic)
DF$long <- paste("This is a veeeeeeeeeeryyyyyyyyyy long line")
DF <- DF[, names(DF)[c(6,1:5)]]

library(Hmisc)
cell.format <- matrix(rep("", nrow(DF) * ncol(DF)), ncol = ncol(DF)) cell.format[which(DF$Freq > 100), ] <- "color{red}"

latex(DF,

       title="",
       caption="Titanic",
       file="",
       cellTexCmds=cell.format,
       rowname="",
       caption.loc="top",
       where="ht")
########################

> R.Version()

$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "7.1"

$year
[1] "2008"

$month
[1] "06"

$day
[1] "23"

$`svn rev`
[1] "45970"

$language
[1] "R"

$version.string
[1] "R version 2.7.1 (2008-06-23)"

2008/7/4, Lauri Nikkinen <lauri.nikkinen_at_iki.fi>:
> R users,
>
> I'm trying to set a column width to one of the columns in a latex
> table (using Hsmic package, latex function). My intention is to get
>
> \begin{tabular}{lp{1.2in}llllll}\hline\hline
>
> Here's an example
>
> ####### R code #########
> DF <- data.frame(Titanic)
> DF$long <- paste("This is a veeeeeeeeeeryyyyyyyyyy long line")
> DF <- DF[, names(DF)[c(6,1:5)]]
>
> library(Hmisc)
> DF.latex <- format.df(DF, na.blank=TRUE, math.row.names=TRUE,
> math.col.names=TRUE)
> #and when I try...
> attr(DF.latex, "col.just")[1] <- "lp{1.2in}"
> #..it does not help
> latex(DF.latex,
> title="",
> caption="Titanic",
> file="",
> rowname="",
> caption.loc="top",
> where="ht")
>
> #I get
> #\begin{tabular}{lllllll}\hline\hline
> ######## end ###########
>
> How should I modify my code to get column width parameter into the latex table?
>
> Thanks
> Lauri
>



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. Received on Mon 07 Jul 2008 - 08:15:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 08:32:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive