Kate Ignatius
2014-Dec-09 02:31 UTC
[R] Printing/Generating/Outputting a Table (Not Latex)
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.
Richard M. Heiberger
2014-Dec-09 04:13 UTC
[R] Printing/Generating/Outputting a Table (Not Latex)
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.
Kate Ignatius
2014-Dec-09 16:43 UTC
[R] Printing/Generating/Outputting a Table (Not Latex)
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.