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? Thanks, Brian
"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
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.
Seemingly Similar Threads
- latex(test, collabel=) returns wrong latex code?
- problem with latex of object summary reverse
- Latex problem in Hmisc (3.8-1) and Mac Os X with R 2.11.1
- Sweave problem, with multicolumn tables from R to LaTeX
- Package Hmisc, functions summary.formula() and latex(), options pdig, pctdig, eps and prmsd