[R] latex() hangs R console

2010-12-07 Thread Michael Friendly

[Env: R 2.11.1, Win Xp, Miktex 2.7]

I've just started using Hmisc::latex and friends, and find that running 
latex() produces the .tex and .dvi files, but hangs,

presumably trying to run yap.  An example is below.  What could be wrong?

My PATH seems OK:
> strsplit(Sys.getenv("path"),';')
$path
 [1] "c:\\program files\\imagemagick-6.4.4-q16"   
"c:\\Rtools\\bin"
 [3] "c:\\Rtools\\perl\\bin"  
"c:\\Rtools\\MinGW\\bin"
 [5] "C:\\Program Files\\MiKTeX 2.7\\miktex\\bin" 
"C:\\WINDOWS\\system32"
 [7] "C:\\WINDOWS"
"C:\\WINDOWS\\System32\\Wbem"
 [9] "C:\\Program Files\\Intel\\DMIX" 
"C:\\Program Files\\ATI Technologies\\ATI.ACE\\"
[11] "C:\\Program Files\\Common Files\\Roxio Shared\\DLLShared\\" 
"C:\\WINDOWS\\system32\\nls"
[13] "C:\\WINDOWS\\system32\\nls\\ENGLISH"
"C:\\Program Files\\SecureCRT\\"
[15] "C:\\Program Files\\IDM Computer Solutions\\UltraEdit-32"
"C:\\Program Files\\SAS\\Shared Files\\Formats"
[17] "C:\\Program Files\\Graphviz2.20\\Bin"   
"C:\\Program Files\\MATLAB\\R2008a\\bin"
[19] "C:\\Program Files\\MATLAB\\R2008a\\bin\\win32"  
"C:\\Program Files\\TortoiseSVN\\bin"
[21] "C:\\Program Files\\HTML Help Workshop"  
"C:\\Program Files\\QuickTime\\QTSystem\\"


Example:

> x <- matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','this 
that')))

> latex(x, file="")
% latex.default(x, file = "")
%
\begin{table}[!tbp]
 \begin{center}
 \begin{tabular}{lrrr}\hline\hline
\multicolumn{1}{l}{x}&\multicolumn{1}{c}{c}&\multicolumn{1}{c}{d}&\multicolumn{1}{c}{this 
that}\tabularnewline

\hline
a&$1$&$3$&$5$\tabularnewline
b&$2$&$4$&$6$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}

> cd("c:/r/test")
> latex(x)
This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.tex
LaTeX2e <2005/12/01>
Babel  and hyphenation patterns for english, dumylang, 
nohyphenation, ge

rman, ngerman, french, loaded.
("C:\Program Files\MiKTeX 2.7\tex\latex\base\report.cls"
Document Class: report 2005/09/16 v1.4f Standard LaTeX document class
("C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.7\tex\latex\geometry\geometry.sty"
("C:\Program Files\MiKTeX 2.7\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.7\tex\latex\geometry\geometry.cfg"))
No file file311f289a.aux.
[1] (file311f289a.aux) )
Output written on file311f289a.dvi (1 page, 372 bytes).
Transcript written on file311f289a.log.

At this point, I have to press ESC after a few minutes to regain the 
console, and no .dvi (yap) window appears.
If I go to the temp directory, C:/WINDOWS/TEMP/Rtmpz0QkT8/, the .dvi 
file is there and double-click

launches yap.

>  optionsCmds("xdvi")
[1] "yap"

Reading the code of print.latex -> show.latex -> show.dvi, I tried 
executing  system() directly, in the forms


> system(paste("yap", "C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi"), 
intern=TRUE)


> system(paste("yap", "C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi"))

However, both of these result in the same behavior -- R console hangs 
until I press ESC.




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] latex() hangs R console

2010-12-07 Thread RICHARD M. HEIBERGER
Michael,

The easiest workaround is to assign the result of the latex() command.

myfilename <- latex(x)
print.default(myfilename)


It looks to me like the insides of the dvi.latex function aren't quite right
for Windows.

Rich

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] latex() hangs R console

2010-12-07 Thread Dennis Murphy
Hi:

I've experienced the same behavior as Dr. Friendly when trying to use
latex() in an Sweave code chunk (with results = tex in the chunk header) on
a Win7 system with 64-bit R (everything up to date). Is the answer the same
in that case?

TIA for your assistance,
Dennis

On Tue, Dec 7, 2010 at 9:52 AM, RICHARD M. HEIBERGER  wrote:

> Michael,
>
> The easiest workaround is to assign the result of the latex() command.
>
> myfilename <- latex(x)
> print.default(myfilename)
>
>
> It looks to me like the insides of the dvi.latex function aren't quite
> right
> for Windows.
>
> Rich
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] latex() hangs R console

2010-12-07 Thread Yihui Xie
I guess I know the answer but I am not completely clear about the
reason; print.latex() calls show.dvi() to open the DVI file using
system(), and under Windows it is usually better using shell() instead
of system(). The help page says shell() is a "friendly" wrapper of
system() under Windows, and this works:

shell(paste("yap", "C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi"))

So if might help to add an additional line for Windows:

if (.Platform$OS.type == 'windows') system = shell

> show.dvi
function (object, width = 5.5, height = 7)
{
viewer <- optionsCmds("xdvi")
cmd <- if (viewer == "yap") {
paste(viewer, object$file)
}
else if (viewer == "kdvi") {
paste(viewer, object$file)
}
else if (viewer == "xdvi") {
paste(viewer, " -paper ", width, "x", height, "in -s 0 ",
object$file, sep = "")
}
else {
paste(viewer, object$file)
}
if (.Platform$OS.type == 'windows') system = shell
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}



Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Tue, Dec 7, 2010 at 8:05 PM, Dennis Murphy  wrote:
> Hi:
>
> I've experienced the same behavior as Dr. Friendly when trying to use
> latex() in an Sweave code chunk (with results = tex in the chunk header) on
> a Win7 system with 64-bit R (everything up to date). Is the answer the same
> in that case?
>
> TIA for your assistance,
> Dennis
>
> On Tue, Dec 7, 2010 at 9:52 AM, RICHARD M. HEIBERGER  wrote:
>
>> Michael,
>>
>> The easiest workaround is to assign the result of the latex() command.
>>
>> myfilename <- latex(x)
>> print.default(myfilename)
>>
>>
>> It looks to me like the insides of the dvi.latex function aren't quite
>> right
>> for Windows.
>>
>> Rich
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] latex() hangs R console

2010-12-08 Thread Michael Friendly

On 12/7/2010 9:35 PM, Yihui Xie wrote:

shell(paste("yap", "C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi"))
I can confirm that using shell() directly on the .dvi file generated by 
latex() works, while system() does not -- it hangs

as before.

However, Yihui's patch, in this form still hangs, so maybe there is 
something else going on here.


`show.dvi` <-
function (object, width = 5.5, height = 7)
{
viewer <- optionsCmds("xdvi")
cmd <- if (viewer == "yap") {
paste(viewer, object$file)
}
else if (viewer == "kdvi") {
paste(viewer, object$file)
}
else if (viewer == "xdvi") {
paste(viewer, " -paper ", width, "x", height, "in -s 0 ",
object$file, sep = "")
}
else {
paste(viewer, object$file)
}
if (.Platform$OS.type == 'windows') system = shell
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) <- environment(latex)



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.