[R] 2 problems with latex.table (quantreg package) - reproducible

From: Kati Schweitzer <kati.schweitzer_at_ims.uni-stuttgart.de>
Date: Wed 10 Jan 2007 - 18:23:43 GMT

Dear all,

When using latex.table from the quantreg package, I don't seem to be able to set table.env=FALSE: when I don't specify caption (as I think I should, when understanding the R help rightly(?)), I get an error message, and when I do so, of course I get one, as well.
The funny thing is, that a table is indeed produced in the first case, so I get a nice tabular, but as I'm using the command within a for - loop, the loop stops due to the error and only one latex table is produced.

Example R-Code:


v1 <- c("val1","val1","val2")
v2 <- c("val1","val2","val2")
tab <- table(v1,v2)

#error - german R error message (saying that caption is missing and has no default :-) ):
#Fehler in cat(caption, "\n", file = fi, append = TRUE) : # Argument "caption" fehlt (ohne Standardwert)


#error - german R error message:
#Fehler in latex.table(tab, table.env = FALSE, caption = "nothing") :
#       you must have table.env=TRUE if caption is given

The second problem is, that - when using latex.table to produce a tabular within a table environment - I would like to specify cgroup with only one value - one multicolumn being a heading for both columns in the table.
But I'm not able to produce latex-compilable code:

latex.table(tab,cgroup="v2",caption="my table")

gives me the following latex code:
\begin{tabular}{|l||c|c|} \hline
tab}&\multicolumn{}{c||}{}&\multicolumn{2}{c|}{\bf v2}\\ \cline{2-3}

\caption{my table\label{tab}}

and within this code the problem is the second multicolumn (&\multicolumn{}{c||}{}), as it has no number specifying how many columns the multicolumn should cover. Latex (at least my version) complains.
When deleting this part of the code, the table is compiled and looks exactly how I want it to look. I'm doing this with a system call and an shell script right now, but this seems pretty ugly to me...

When I specify 2 columns, this problem doesn't occur: latex.table(tab,cgroup=c("blah","v2"),caption="my table")

I'm running R Version 2.3.0 (2006-04-24) on a linux machine Fedora Core 5 (i386).

Can anyone help me find my mistakes?

Thanks a lot
... and sorry for my bad English and potential newbie mistakes!! Kati

R-help@stat.math.ethz.ch 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 Thu Jan 11 05:29:27 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 19:31:38 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.