# [R] using latex() in R for Unix

Brian Quinif bquinif at gmail.com
Wed Apr 5 22:47:24 CEST 2006

```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()

library(Matching)
library(Hmisc)

#make up some data
X <- matrix(rnorm(1000*5), ncol=5)
Y1 <- as.vector(rnorm(1000))
Tr <- c(rep(1,500),rep(0,500))

#estimate nearest neighbor, 1-1 matching, ATT
a <- Match(Y=Y1, X=X, Tr=Tr, M=1)
summary(a)

#make up some more data
Y2 <- as.vector(rnorm(1000))

#estimate nearest neighbor, 1-1 matching, ATT
b <- Match(Y=Y2, X=X, Tr=Tr, M=1)
summary(b)

#Generate table of estimates
Estimates <- matrix(c(a\$est, b\$est, a\$se, b\$se),nrow=2)
rownames(Estimates) = c("a","b")
colnames(Estimates) = c("Estimate","Standard Error")
print(Estimates)

#I use the next line of code for running in Windows--it works, and I
can find the file out.tex
#latex(Estimates, file='out.tex', rowlabel='',digits=3)

#I use the next line of code for running in Unix--I get an error
message saying the file/directory does not exist
#latex(Estimates, file='/home/b/bquinif/bq/9095/out.tex', rowlabel='',digits=3)

05 Apr 2006 22:29:54 +0200, Peter Dalgaard <p.dalgaard at biostat.ku.dk>:
> "Brian Quinif" <bquinif at gmail.com> writes:
>
> > I am using R for Unix and want to make some LaTeX tables.  I have
> > already played around in R for Windows and have succeeded in making
> > tables that I want using the following code:
> >
> > latex(Estimates, file='out.tex', rowlabel='',digits=3)
> >
> > However, when I use this code in Unix, I can never find the file
> > "out.tex".  I assumed that R would send the file to whatever directory
> > I was working in, but that does not seem to be the case.  So, I tried
> > specifiying the exact location where I want the file:
> >
> > latex(Estimates, file='/home/b/bquinif/bq/9095/out.tex', rowlabel='',digits=3)
> >
> > When I do that, I get an error message sayin that the file/directory
> > does not exist.  I have written lots of files from Stata to locations
> > specified like above, so I don't understand what's going on.
> >
> > Can anyone help me straighten this out?
>
> I assume you mean latex() from the Hmisc package? You might want to
> ask its maintainer. I can't reproduce your problem though; I get the
> file nicely in the current directory. (I got slightly bugged by
> Frank's idea of having the print method run latex on the file and fire
> up a viewer - didn't play well with a terminal login. However, that's
> completely unrelated).
>
> Can you give a completely reproducible example that others might try?
>
> --
>   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907
>

```