[R] Help using Hmisc / Latex

Kevin Bartz kbartz at loyaltymatrix.com
Wed Aug 25 19:32:49 CEST 2004

I'm afraid you need to modify your approach. You're trying to pass latex an
lm object, which latex doesn't know how to handle. Also, latex isn't
supposed to produce a full .tex file; it generates just a "core" that's
loaded into a "shell" when you run dvi.

Here's an example of how you might use it appropriately:

l <- latex(summary(lm(b ~ a, data.frame(a = 1:5, b = 1:5)))$coefficients)
d <- dvi(l)

If you want the full .tex file, you can read the console output after
running dvi(l) to find out where the .tex tempfile lives and copy it over to
someplace usable. Obviously, you'll have to tweak the row and column names
as well as the rounding to suit your preferences.

If you're just looking for graphical output--not necessarily a .tex file--I
have a function grid.table, now being rolled into a package I will soon
release, which uses grid to place a data frame (neatly) on the graphics
device. You could then wrap the command around a pdf(), postscript() or any
other device to produce an appropriate display. Let me know if you'd like me
to send over my working version of the binaries.


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Joao Pedro W. de
Sent: Wednesday, August 25, 2004 4:02 AM
To: R-help at stat.math.ethz.ch
Subject: [R] Help using Hmisc / Latex

Dear R users,
I'm trying to automatically generate a *.tex file with the output of an OLS
estimation. Some people suggested to use the latex function on the Hmisc
package. I'm having a bit of trouble to properly specify this function (I'm
not a very experienced R user). Below you will find an example, of what I'm

## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept
out  <- latex(lm.D90)
latex(out, model1, file="")

When I run this code, I get an output which does not attend my needs.

First, I could not figure out how to print the variable names. Second I'm
not sure how I can select only the coefficients and the std. errors to be
inserted on the output. Third, I was wondering if there is any way I can
automatically generate significance level indicators next to either the
coefficients or the std erros. Forth, is there any way I can aumtomaticaly
insert some of model fitting statistics? Fifth, is it possible to specify
this function to save the std. error under the coefficient?

I'm sure this are quite basic questions, but my attempts to fiddle with the
parameters in the model took me nowhere. 

Many thanks once again,

Joao Pedro

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!

More information about the R-help mailing list