[R] Printing/Generating/Outputting a Table (Not Latex)

Prof Brian Ripley
Tue, 09 Dec 2014 21:02:51 -0000

On 09/12/2014 20:47, Richard M. Heiberger wrote:
> the last one is wrong.  That is the one for which I don't know the
> right answer on linux.
>
> 'xdvi' displays dvi files.  you need to display a pdf file.
> whatever is the right program on linux to display pdf files is what
> belongs there.
>
> On Macintosh we can avoid knowing by using 'open', which means use
the
> system standard.
> I don't know what the linux equivalent is, either the exact program or
> the instruction to use the standard.

xdg-open (but like OS X it depends on having the right associations set).

>
> On Tue, Dec 9, 2014 at 3:36 PM, Kate Ignatius <kate.ignatius at
gmail.com> wrote:
>> I set these options:
>>
>> options(latexcmd='pdflatex')
>> options(dviExtension='pdf')
>> options(xdvicmd='xdvi')
>>
>> Maybe one too many?  I'm running in Linux.
>>
>>
>>
>> On Tue, Dec 9, 2014 at 3:24 PM, Richard M. Heiberger <rmh at
temple.edu> wrote:
>>> It looks like you skipped the step of setting the options.
>>> the latex function doesn't do pdflatex (by default it does
regular
>>> latex) unless you set the options
>>> as I indicated.
>>>
>>> On Tue, Dec 9, 2014 at 3:11 PM, Kate Ignatius <kate.ignatius at
gmail.com> wrote:
>>>> Ah yes, you're right.
>>>>
>>>> The log has this error:
>>>>
>>>> ! LaTeX Error: Missing \begin{document}.
>>>>
>>>> Though can't really find much online on how to resolve it.
>>>>
>>>> On Tue, Dec 9, 2014 at 1:15 PM, Jeff Newmiller <jdnewmil at
dcn.davis.ca.us> wrote:
>>>>> pdflatex appears to have run, because it exited. You should
look at the tex log file, the problem is more likely that the latex you sent out
to pdflatex was incomplete.
>>>>>
---------------------------------------------------------------------------
>>>>> Jeff Newmiller                        The     .....
.....  Go Live...
>>>>> DCN:<jdnewmil at dcn.davis.ca.us>        Basics:
##.#.       ##.#.  Live Go...
>>>>>                                        Live:   OO#.. Dead:
OO#..  Playing
>>>>> Research Engineer (Solar/Batteries            O.O#.
#.O#.  with
>>>>> /Software/Embedded Controllers)               .OO#.
.OO#.  rocks...1k
>>>>>
---------------------------------------------------------------------------
>>>>> Sent from my phone. Please excuse my brevity.
>>>>>
>>>>> On December 9, 2014 8:43:02 AM PST, Kate Ignatius
<kate.ignatius at gmail.com> wrote:
>>>>>> Thanks!  I do get several errors though when running on
Linux.
>>>>>>
>>>>>> Running your code, I get this:
>>>>>>
>>>>>> Error in system(cmd, intern = TRUE, wait = TRUE) :
>>>>>> error in running command
>>>>>>
>>>>>> Fiddling around with the code and running this:
>>>>>>
>>>>>> tmp <- matrix(1:9,3,3)
>>>>>> tmp.tex <- latex(tmp, file='tmp.tex')
>>>>>> print.default(tmp.tex)
>>>>>> tmp.dvi <- dvi(tmp.tex)
>>>>>> tmp.dvi
>>>>>> tmp.tex
>>>>>> dvips(tmp.dvi)
>>>>>> dvips(tmp.tex)
>>>>>> library(tools)
>>>>>> texi2dvi(file='tmp.tex', pdf=TRUE, clean=TRUE)
>>>>>>
>>>>>> I get this:
>>>>>>
>>>>>> Error in texi2dvi(file="tmp.tex",,  :
>>>>>>   Running 'texi2dvi' on 'tmp.tex'
failed.
>>>>>> Messages:
>>>>>> /usr/bin/texi2dvi: pdflatex exited with bad status,
quitting.
>>>>>>
>>>>>> I've read that it may have something to do with the
path of pdflatex.
>>>>>>
>>>>>> Sys.which('pdflatex')
>>>>>>
>>>>>>            pdflatex
>>>>>>
>>>>>> "/usr/bin/pdflatex"
>>>>>>
>>>>>>
>>>>>> Sys.which('texi2dvi')
>>>>>>
>>>>>>            texi2dvi
>>>>>>
>>>>>> "/usr/bin/texi2dvi"
>>>>>>
>>>>>>> file.exists(Sys.which('texi2dvi'))
>>>>>>
>>>>>> [1] TRUE
>>>>>>
>>>>>>> file.exists(Sys.which('pdflatex'))
>>>>>>
>>>>>> [1] TRUE
>>>>>>
>>>>>> Is there a specific path I should be giving with
pdflatex and/or
>>>>>> 'texi2dvi to make this work?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> On Mon, Dec 8, 2014 at 11:13 PM, Richard M. Heiberger
<rmh at temple.edu>
>>>>>> wrote:
>>>>>>> yes of course, and the answer is latex() in the
Hmisc package.
>>>>>>> Why were you excluding it?
>>>>>>> Details follow
>>>>>>>
>>>>>>> Rich
>>>>>>>
>>>>>>>
>>>>>>> The current release of the Hmisc package has this
capability on
>>>>>>> Macintosh and Linux.
>>>>>>> For Windows, you need the next release 3.14-7 which
is available now
>>>>>> at github.
>>>>>>>
>>>>>>> ## windows needs these lines until the new Hmisc
version is on CRAN
>>>>>>> install.packages("devtools")
>>>>>>> devtools::install_github("Hmisc",
"harrelfe")
>>>>>>>
>>>>>>> ## All operating systems
>>>>>>> options(latexcmd='pdflatex')
>>>>>>> options(dviExtension='pdf')
>>>>>>>
>>>>>>> ## Macintosh
>>>>>>> options(xdvicmd='open')
>>>>>>>
>>>>>>> ## Windows, one of the following
>>>>>>>
>>>>>>
options(xdvicmd='c:\\progra~1\\Adobe\\Reader~1.0\\Reader\\AcroRd32.exe')
>>>>>>> ## 32-bit windows
>>>>>>>
>>>>>>
options(xdvicmd='c:\\progra~2\\Adobe\\Reader~1.0\\Reader\\AcroRd32.exe')
>>>>>>> ## 64 bit windows
>>>>>>>
>>>>>>> ## Linux
>>>>>>> ## I don't know the xdvicmd value
>>>>>>>
>>>>>>>
>>>>>>> ## this works on all R systems
>>>>>>> library(Hmisc)
>>>>>>> tmp <- matrix(1:9,3,3)
>>>>>>> tmp.dvi <- dvi(latex(tmp))
>>>>>>> print.default(tmp.dvi) ## prints filepath of the
pdf file
>>>>>>> tmp.dvi  ## displays the pdf file on your screen
>>>>>>>
>>>>>>> On Mon, Dec 8, 2014 at 9:31 PM, Kate Ignatius
>>>>>> <kate.ignatius at gmail.com> wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have a simple question.  I know there are
plenty of packages out
>>>>>>>> there that can provide code to generate a table
in latex.  But I was
>>>>>>>> wondering whether there was one out there where
I can generate a
>>>>>> table
>>>>>>>> from my data (which ever way I please) then
allow me to save it as a
>>>>>>>> pdf?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> K.
>>>>>>>>
>>>>>>>> ______________________________________________
>>>>>>>> R-help at r-project.org mailing list -- To
UNSUBSCRIBE and more, see
>>>>>>>> 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 at r-project.org mailing list -- To UNSUBSCRIBE
and more, see
>>>>>> 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 at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>


--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK