Re: [R] using latex() in R for Unix

From: Paul Johnson <pauljohn32_at_gmail.com>
Date: Fri 05 May 2006 - 14:26:58 EST

This thread piqued my interest in how to use Hmisc latex() to produce the tables that I actually want, rather than the ones that come out by default. Actually, I'd be glad to use R2HTML or any other tool if I can make the output suit my taste.

 Here's a small working example that does not require any special libraries.

x <- rnorm(100)
y <- rnorm(100)
 mylm <- lm(y~x)
 Estimates <- cbind(coef(mylm), sqrt(diag(vcov(mylm))))  colnames(Estimates) <- c("OLS estimate","std. error")  rownames(Estimates) <- c("Intercept","Education")  latex(Estimates,file="/home/pauljohn/test4.tex",digits=4)

That creates the top part of the table like I want it, except there are no stars on the standard errors.

I want to add the diagnostic information, sample size, the R-square, and root mean square error:

sumobj <- summary(mylm)
## tedious pasting alert:
sumStat <- paste("N= ",sum(sumobj$df[-1]), ", R^2 =", sumobj$r.squared, ", RMSE = ", sumobj$sigma)

# The following does not have the desired effect because it creates and appends a whole new table

latex(sumStat, file="/home/pauljohn/test4.tex", append=T)

How can I "snug up" sumStat right at the end of the table?

pj

On 4/5/06, Frank E Harrell Jr <f.harrell@vanderbilt.edu> wrote:
> Peter Dalgaard wrote:
> > "Brian Quinif" <bquinif@gmail.com> writes:
> >
> >
> >>Yes, Peter, I do mean the later() function from the Hmsic package.
> >>Below is a reproducible example. Also, does anyone know how to stop R
> >>from automatically running LaTeX on the file produced by latex()
> >
> >
> > The last bit is easy. It's the print method that does that, so just
> > don't print. E.g.
> >
> > invisible(latex(....))

>

> Or do w <- latex(.., file='...')
>

> Frank
> >
>
>

> --
> Frank E Harrell Jr Professor and Chair School of Medicine
> Department of Biostatistics Vanderbilt University
>
> ______________________________________________
> 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
>
--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________
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
Received on Fri May 05 14:46:57 2006

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 Fri 05 May 2006 - 16:10:04 EST.

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