Re: [R] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
I didn't see that in the Adobe help file.  There was some reference in the
Adobe online forum
http://forums.adobe.com/
but the first few hits were queries, not responses to the query.  If you
pursue it, please
report success back to the list.

Rich



On Thu, May 13, 2010 at 4:08 PM, Felipe Carrillo
wrote:

>   I was used to see the dvi file with menus and options to rotate  the
> document and was expecting the pdf file
>  to landscape and be rotated automatically. Is there anywhere in your
> function that I can have the pdf to be
> rotated clockwise automatically?
>

[[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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Felipe Carrillo
I was used to see the dvi file with menus and options to rotate  the document 
and was expecting the pdf file
 to landscape and be rotated automatically. Is there anywhere in your function 
that I can have the pdf to be 
rotated clockwise automatically?



>
>From: RICHARD M. HEIBERGER 
>To: Felipe Carrillo 
>Cc: Erik Iverson ; r-help@r-project.org; Charles Dupont 
>; Frank E Harrell Jr 
>Sent: Thu, May 13, 2010 1:00:43 PM
>Subject: Re: [R] a question about "latex" in Hmisc and .dvi file
>
>
>
>Your example showed up in landscape for me on the pdf file.
>I needed to rotate the image in the Adobe Reader.
>
>I like the appearance better with
>  show.dvi(dvi(x.tex <- latex(report,landscape=TRUE),  width=8.5, height=11))
>where I changed the paper size in the dvi() command.
>
>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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
Your example showed up in landscape for me on the pdf file.
I needed to rotate the image in the Adobe Reader.

I like the appearance better with
  show.dvi(dvi(x.tex <- latex(report,landscape=TRUE),  width=8.5,
height=11))
where I changed the paper size in the dvi() command.

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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Felipe Carrillo
That function works nicely generating the pdf on the fly instead of the dvi 
file,
however, consider the example below. I can't get the pdf to landscape.

report <- structure(list(Date = c("2/26/2010", "2/27/2010", "2/28/2010", 
"3/1/2010", "3/2/2010", "3/3/2010", "3/4/2010", "3/5/2010", "3/6/2010", 
"3/7/2010", "3/8/2010", "3/9/2010", "3/10/2010", "3/11/2010", 
"Biweekly Lower 90% Confidence Interval", "Biweekly Total", "Biweekly Upper 90% 
Confidence Interval", 
"Brood-year  Lower 90% Confidence Interval", "Brood Year Total", 
"Brood-year Upper 90% Confidence Interval"), Run1 = c("0 ( ? )", 
"n (0 ? 0)", "357 (123 ? 123)", "144 (95 ? 152)", "73 (126 ? 152)", 
"43 (108 ? 108)", "n (0 ? 0)", "270 (101 ? 140)", "121 (111 ? 112)", 
"0 ( ? )", "34 (111 ? 111)", "102 (111 ? 140)", "0 ( ? )", "35 (125 ? 125)", 
"-537", "1,425", "3,388", "2,578,499", "4,455,877", "6,333,255"
), Run2 = c("0 ( ? )", "n (0 ? 0)", "0 ( ? )", "99 (65 ? 71)", 
"0 ( ? )", "86 (66 ? 76)", "n (0 ? 0)", "0 ( ? )", "40 (66 ? 66)", 
"0 ( ? )", "33 (74 ? 74)", "0 ( ? )", "35 (66 ? 66)", "35 (70 ? 70)", 
"-549", "402", "1,353", "74,306", "314,206", "541,552"), Run3 = c("7,002 (33 ? 
39)", 
"n (0 ? 0)", "130,342 (29 ? 57)", "22,741 (31 ? 56)", "8,365 (31 ? 53)", 
"5,962 (33 ? 60)", "n (0 ? 0)", "22,461 (30 ? 61)", "12,485 (31 ? 55)", 
"7,352 (31 ? 56)", "2,908 (32 ? 48)", "3,265 (27 ? 48)", "1,993 (30 ? 55)", 
"1,445 (33 ? 62)", "35,097", "296,085", "557,074", "2,249,920", 
"7,347,719", "12,058,021"), Run4 = c("0 ( ? )", "n (0 ? 0)", 
"0 ( ? )", "48 (196 ? 196)", "0 ( ? )", "0 ( ? )", "n (0 ? 0)", 
"0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", "35 (185 ? 185)", 
"0 ( ? )", "-375", "103", "580", "98,734", "225,976", "353,217"
), Run5 = c("0 ( ? )", "n (0 ? 0)", "0 ( ? )", "0 ( ? )", "0 ( ? )", 
"0 ( ? )", "n (0 ? 0)", "0 ( ? )", "0 ( ? )", "0 ( ? )", "0 ( ? )", 
"0 ( ? )", "0 ( ? )", "0 ( ? )", "0", "0", "0", "-184", "977", 
"2,138")), .Names = c("Date", "Run1", "Run2", "Run3", 
"Run4", "Run5"), class = "data.frame", row.names = c(NA, 
-20L))
report
require(stringr)
report <- t(apply(report, 1, function(x) {str_replace(x, "\\?", "-")}))
library(Hmisc)
 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 if (basename(viewer) == "AcroRd32") {
  object$file <- sub("dvi", "pdf", object$file)
    paste(viewer, object$file)
    }
    else {
    paste(viewer, object$file)
    }
    system(cmd, intern = TRUE, wait = TRUE)
    invisible(NULL)
}
environment(show.dvi) <- environment(print.dvi)
 
options(latexcmd="pdflatex",
    xdvicmd="c:/Progra~1/Adobe/Reader~1.0/Reader/AcroRd32")
    # Portrait (default) it doesn't fit
 show.dvi(dvi(x.tex <- latex(report)))
 # so let's try to Landscape
 show.dvi(dvi(x.tex <- latex(report,landscape=TRUE)))
 
  The table itself gets landscaped but not the actual pdf
  If I run tex2dvi(report.tex,pdf=TRUE) then everything gets
 landscaped nicely. Do I need anything else inside the latex function?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA


>
>From: RICHARD M. HEIBERGER 
>To: Erik Iverson 
>Cc: Felipe Carrillo ; r-help@r-projec

Re: [R] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
>
>  At least I thought it did, since I believe show.dvi is an exported
> function, can't you just overwrite it in your global environment and
> anything that calls it will use your copy?  I'll have to  look into how I
> got your code working on my system, because I know I didn't use that trick!
>
I thought so, but it didn't work that way on my machine.  Usually when
functions inside a
namespace call each other, any replacement must also be in the namespace.
When I do
this type of thing, I usually need to rebuild a local copy of the package to
get into the
namespace.

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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson



Notice that I didn't quite get my function into the Hmisc environment
and that is why you need the awkward phrase
show.dvi(dvi(x.tex <- latex(x)))
instead of the smooth phrase
latex(x)



Somehow with my own data and not using the awkward bit, it worked on my 
Linux machine?  At least I thought it did, since I believe show.dvi is 
an exported function, can't you just overwrite it in your global 
environment and anything that calls it will use your copy?  I'll have to 
 look into how I got your code working on my system, because I know I 
didn't use that trick!


--Erik

__
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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
On Thu, May 13, 2010 at 12:46 PM, Erik Iverson  wrote:

> Looks good.


Thank you.


>   I came up with something on my own which was basically to re-write
> print.latex.  I call pdflatex a few times because with the longtable
> package, sometimes things don't line up right until you run pdflatex
> multiple times.  I think mine is less flexible though, and I like your
> solution better.
>
> The only thing I can see to make your solution more flexible is to note
> that there is already options("pdfviewer") in R, so maybe you could just use
> whatever that is for options("xdvicmd") and then in show.dvi, you can test
>
I set the value of xdvicmd correctly for the pdf viewer on my machine.  It
would be possible
to use options()$pdfviewer instead.  That is part of the smoothing that I
have implicitly
asked Charles and Frank to do.  Also, to make things more automatic.
Notice that I didn't quite get my function into the Hmisc environment
and that is why you need the awkward phrase
show.dvi(dvi(x.tex <- latex(x)))
instead of the smooth phrase
latex(x)

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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson
Looks good.  I came up with something on my own which was basically to 
re-write print.latex.  I call pdflatex a few times because with the 
longtable package, sometimes things don't line up right until you run 
pdflatex multiple times.  I think mine is less flexible though, and I 
like your solution better.


The only thing I can see to make your solution more flexible is to note 
that there is already options("pdfviewer") in R, so maybe you could just 
use whatever that is for options("xdvicmd") and then in show.dvi, you 
can test


if(viewer == options("pdfviewer")) {
...
}

--Erik

RICHARD M. HEIBERGER wrote:
Here is the full repair for the latex functions in Hmisc to make 
pdflatex work in Windows.
This version is still slightly awkward.  I hope that Charles and Frank 
will smooth it out

and put it in their next release.
 
I added two new options() and revised show.dvi so it will use them.


Rich
 
 
 
library(Hmisc)
 
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 if (basename(viewer) == "AcroRd32") {
  object$file <- sub("dvi", "pdf", object$file)
paste(viewer, object$file)
}
else {
paste(viewer, object$file)
}
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) <- environment(print.dvi)
 
options(latexcmd="pdflatex",

xdvicmd="c:/Progra~1/Adobe/Reader~1.0/Reader/AcroRd32")
 
x <- matrix(1:24, 6,4, dimnames=list(letters[1:6], LETTERS[1:4]))

show.dvi(dvi(x.tex <- latex(x)))
paste(getwd(), x.tex$file, sep="/")  ## location of the table itself
## The tex file with headers and the pdf file are in the directory
## given in the printed output from dvi().


__
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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
Here is the full repair for the latex functions in Hmisc to make pdflatex
work in Windows.
This version is still slightly awkward.  I hope that Charles and Frank will
smooth it out
and put it in their next release.

I added two new options() and revised show.dvi so it will use them.

Rich



library(Hmisc)

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 if (basename(viewer) == "AcroRd32") {
  object$file <- sub("dvi", "pdf", object$file)
paste(viewer, object$file)
}
else {
paste(viewer, object$file)
}
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) <- environment(print.dvi)

options(latexcmd="pdflatex",
xdvicmd="c:/Progra~1/Adobe/Reader~1.0/Reader/AcroRd32")

x <- matrix(1:24, 6,4, dimnames=list(letters[1:6], LETTERS[1:4]))
show.dvi(dvi(x.tex <- latex(x)))
paste(getwd(), x.tex$file, sep="/")  ## location of the table itself
## The tex file with headers and the pdf file are in the directory
## given in the printed output from dvi().

[[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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson



Felipe Carrillo wrote:

HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
"The print method for "latex" objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file)."
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks


I don't work in a Windows environment, but I think the process is the 
same here.


You have to know what the print.latex function in Hmisc is doing.  It 
simply calls show.latex.  If you look at the source for show.latex, it 
looks at the latex object passed to it, and inspects the file argument. 
 If the file argument is the empty string ( "" ), it does not attempt 
to show the resulting output in a dvi.  If the file argument is a file 
name, show.latex will call dvi.latex on the object, which will wrap the 
latex code in some basic latex, and call optionsCmds("latex") on the file.


This is by default set to

> optionsCmds("latex")
[1] "/usr/bin/latex"

This will of course create a dvi and attempt to display it with 
show.dvi, which will in turn use


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

to display the resulting file.

I'm guessing MikTex comes with pdflatex, just like it comes with a 
binary called latex.  You'd just have to find it and make sure it's in 
your path.


Then, by setting the relevant options I just described above to pdflatex 
and a suitable pdf viewer, you might get what you want.  But there might 
be other things I haven't thought of that will prohibit this from 
working.  In fact, it looks like dvi.latex naturally assumes the 
extension .dvi from its output, and so this may not work.  You/I might 
have to write separate functions to carry this out it appears.  Of 
course, someone else may have already, and I just don't know about it.


--Erik

__
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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Duncan Murdoch

On 13/05/2010 10:48 AM, Uwe Ligges wrote:

On 13.05.2010 16:32, Felipe Carrillo wrote:
> HI:
> If you don't mind me asking this question about latex:
> Based on Duncan's comment:
> "The print method for "latex" objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file)."
> Where in MikTex can I change to pdflatex? everytime I use latex it displays 
the dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks


Run pdflatex rather than latex?
  


Or if using texify, use the --pdf option.

Duncan Murdoch

Uwe Ligges


> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish&  Wildlife Service
> California, USA
>
>
>
> - Original Message 
>> From: Duncan Murdoch
>> To: "Shi, Tao"
>> Cc: r-help@r-project.org
>> Sent: Wed, May 12, 2010 1:40:50 PM
>> Subject: Re: [R] a question about "latex" in Hmisc
>>
>> On 12/05/2010 4:33 PM, Shi, Tao wrote:
>> Hi Ista,
>>
>> Thanks
>> for the reply!
>>
>> You actually misunderstood me.  I never
>> objected the "tmp<- latex(x)" method (in fact, that's what I'm doing now in
>> my .Rnw file).  As I stated in my original post, I'm simply curious about
>> what causes the error window and wanted to get to the bottom of
>> it.
>>
> latex(x) returns an object of class "latex".  When
>> you don't assign it, it prints.  The print method for "latex" objects tries
>> to run latex and then display the resulting .dvi file.  (Or maybe it runs
>> pdflatex and displays the .pdf file).
>
> If you can't run latex, you can't
>> print those objects.  That's why you're getting an error.
>
> Duncan
>> Murdoch
>
> __
>> ymailto="mailto:R-help@r-project.org";
>> href="mailto:R-help@r-project.org";>R-help@r-project.org mailing list
>> href="https://stat.ethz.ch/mailman/listinfo/r-help"; target=_blank
>>> 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.



__
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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Uwe Ligges



On 13.05.2010 16:32, Felipe Carrillo wrote:

HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
"The print method for "latex" objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file)."
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks



Run pdflatex rather than latex?

Uwe Ligges



Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish&  Wildlife Service
California, USA



- Original Message 

From: Duncan Murdoch
To: "Shi, Tao"
Cc: r-help@r-project.org
Sent: Wed, May 12, 2010 1:40:50 PM
Subject: Re: [R] a question about "latex" in Hmisc

On 12/05/2010 4:33 PM, Shi, Tao wrote:
Hi Ista,

Thanks
for the reply!

You actually misunderstood me.  I never
objected the "tmp<- latex(x)" method (in fact, that's what I'm doing now in
my .Rnw file).  As I stated in my original post, I'm simply curious about
what causes the error window and wanted to get to the bottom of
it.


latex(x) returns an object of class "latex".  When

you don't assign it, it prints.  The print method for "latex" objects tries
to run latex and then display the resulting .dvi file.  (Or maybe it runs
pdflatex and displays the .pdf file).


If you can't run latex, you can't

print those objects.  That's why you're getting an error.


Duncan

Murdoch


__

ymailto="mailto:R-help@r-project.org";
href="mailto:R-help@r-project.org";>R-help@r-project.org mailing list
href="https://stat.ethz.ch/mailman/listinfo/r-help"; target=_blank

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.


__
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] a question about "latex" in Hmisc and .dvi file

2010-05-13 Thread Felipe Carrillo
HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
"The print method for "latex" objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file)."
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA



- Original Message 
> From: Duncan Murdoch 
> To: "Shi, Tao" 
> Cc: r-help@r-project.org
> Sent: Wed, May 12, 2010 1:40:50 PM
> Subject: Re: [R] a question about "latex" in Hmisc
> 
> On 12/05/2010 4:33 PM, Shi, Tao wrote:
> Hi Ista,
> 
> Thanks 
> for the reply!
> 
> You actually misunderstood me.  I never 
> objected the "tmp <- latex(x)" method (in fact, that's what I'm doing now in 
> my .Rnw file).  As I stated in my original post, I'm simply curious about 
> what causes the error window and wanted to get to the bottom of 
> it.
>  
latex(x) returns an object of class "latex".  When 
> you don't assign it, it prints.  The print method for "latex" objects tries 
> to run latex and then display the resulting .dvi file.  (Or maybe it runs 
> pdflatex and displays the .pdf file).

If you can't run latex, you can't 
> print those objects.  That's why you're getting an error.

Duncan 
> Murdoch

__
> ymailto="mailto:R-help@r-project.org"; 
> href="mailto:R-help@r-project.org";>R-help@r-project.org mailing list
> href="https://stat.ethz.ch/mailman/listinfo/r-help"; target=_blank 
> >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.