[R] using latex() in R for Unix

Richard M. Heiberger rmh at temple.edu
Fri May 5 16:48:06 CEST 2006


The difficulty you are running into is related to the fact that
print methods return their argument as their value.  They do not
return a representation of the text that appears on the screen.
At some level, it looks like the intent is to capture the screen text
and reformat it for LaTeX.  This is not easily done without getting
inside the print method.

You can get an effect close to what you want with the single statement
  tmp <- latex(list(Estimates, sumStat))  ## assignment prevents automatic printing
but it will still produce two table environments, one for each component
of the list.

The result you are looking for is not a simple rectangular array.
We have zillions of arguments in latex() for controlling the appearance
of rectangular arrays.  The types of controls that are needed for more
general structures are more general and we don't have all that you would want.
You might want to look at the insert.bottom argument and the caption and caption.loc
arguments.

For full control, you have the choice of doing formatting on the R side or
on the LaTeX side.  You can write 
  sumStat <- paste("\multicolumn{3}{l}{", "N=  ",sum(sumobj$df[-1]), ", R^2 =", 
                   sumobj$r.squared, ", RMSE = ", sumobj$sigma, "}")
on the R side.  Or you can edit the latex file to add
the \multicolumn.  Since you will need to edit the latex anyway to move
the line from its own table to the bottom of the first table,
I think it would be easier to do everything on the LaTeX side.




More information about the R-help mailing list