2

Take this sample data frame

df <- "A B C
1  1 2 3
2  4 5 6
3  7 8 9"
df1 <- read.table(textConnection(df), header=TRUE)

I want to save it as a table on a .tex file. The function

require(Hmisc)
latex(df1,title="TeX/df1prova")

saves the file, but R does not stop running. The output I get is

> latex(df1,title="TeX/df1prova")
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9)
entering extended mode
(C:/Users/Simone/AppData/Local/Temp/Rtmpw116kM/file1bd01a163c06.tex
LaTeX2e <2016/03/31> patch level 3
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\report.cls"
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.cfg"))
No file file1bd01a163c06.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
[1] (file1bd01a163c06.aux) )
Output written on file1bd01a163c06.dvi (1 page, 444 bytes).
Transcript written on file1bd01a163c06.log.

Any clue? thanks!

simone
  • 577
  • 1
  • 7
  • 15

2 Answers2

3

Sorry this answer comes 6 month late. This is explained in the latex help files (look at the examples). When you run the latex command, it creates an object of class "latex" which is automatically printed by the latex print method. To avoid this, pass it to a variable

mytex <- latex(df1,title="TeX/df1prova")

This will not invoke the print method, but will write the result in the file.

Cedric
  • 2,412
  • 17
  • 31
-1

I know it's late, but I think the reason is that when you run the latex( ) command, R creates a .tex file inside your working directory and a .dvi file for the latex file inside a temporary folder inside C:\users (Not inside your working directory). For example, in my case, the .dvi file was saved in

"C:\\Users\\domjo\\AppData\\Local\\Temp\\Rtmp6XUHct\\file2d08490a3831.dvi"

R keeps running because, it is either confused about the location of this .dvi file or it can;t access the folders inside C:\\Users\\domjo\\AppData\\Local\\Temp.

So here is what I did. Opened Rstudio with admin privileges and opened this folder location manually when doing it the first time.

After opening the file .dvi once, I never faced this issue again, with any other code.