harrelfe / Hmisc

Harrell Miscellaneous
Other
208 stars 81 forks source link

cellTexCmds with cgroup in latex() #54

Open LaurenSamuels opened 7 years ago

LaurenSamuels commented 7 years ago

Hi Frank- I updated to Hmisc_3.17-4 recently, and I noticed that now the color-coding in some of my latex tables is off by a column when I also use column groups. Here's an example:

sumtbl <- data.frame(matrix(1:18, ncol= 6))
table.cellTex <- matrix("", ncol= ncol(sumtbl), 
        nrow= nrow(sumtbl))
table.cellTex[, 4] <- rep("color{red}", nrow(sumtbl))

# This works as expected
latex(sumtbl,
    file        = '',
    colheads    = rep(letters[25:26], 3), 
    cellTexCmds = table.cellTex
)    

# With this one, the 5th column is red instead of the 4th.
# I can see a new empty column is being inserted into the latex code between the two cgroups.
latex(sumtbl,
    file        = '',
    cgroup      = LETTERS[1:3],
    n.cgroup    = rep(2, 3),
    colheads    = rep(letters[25:26], 3), 
    cellTexCmds = table.cellTex
)    

Thank you- Laurie