Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typesetting of R objects is problematic #15068

Open
gvol opened this issue Aug 20, 2013 · 0 comments
Open

Typesetting of R objects is problematic #15068

gvol opened this issue Aug 20, 2013 · 0 comments

Comments

@gvol
Copy link

gvol commented Aug 20, 2013

Typesetting of R objects requires the R package Hmisc. Unfortunately, even after this is installed things are a bit weird. Calling latex the first time fails, but succeeds thereafter.

+--------------------------------------------------------------------+
| Sage Version 5.10, Release Date: 2013-06-17                        |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
+--------------------------------------------------------------------+
sage: latex(r("1+2"))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-1-0a8044ad4f2e> in <module>()
----> 1 latex(r("1+2"))

/Users/ivanandres/SageStuff/sage-5.10/local/lib/python2.7/site-packages/sage/misc/latex.pyc in __call__(self, x, combine_all)
    934         """
    935         if has_latex_attr(x):
--> 936             return LatexExpr(x._latex_())
    937         try:
    938             f = latex_table[type(x)]

/Users/ivanandres/SageStuff/sage-5.10/local/lib/python2.7/site-packages/sage/interfaces/r.pyc in _latex_(self)
   1851             P.library('Hmisc')
   1852         except ImportError:
-> 1853             raise RuntimeError, "The R package 'Hmisc' is required for R to LaTeX conversion, but it is not available."
   1854         return LatexExpr(P.eval('latex(%s, file="");'%self.name()))
   1855

RuntimeError: The R package 'Hmisc' is required for R to LaTeX conversion, but it is not available.
sage: latex(r("1+2"))
% latex.default(sage1, file = "")
%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{r}
\hline\hline
\multicolumn{1}{c}{}\tabularnewline
\hline
$3$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}

This seems to be because of how the output from R is parsed. When Hmisc is first loaded it prints a "banner" which is misparsed as failing. After that, things work fine since no banner is printed. I don't know anything about R, but perhaps we could pass quietly=TRUE to require to avoid the banner?


sage: r.library('Hmisc')
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-9e4e08408e41> in <module>()
----> 1 r.library('Hmisc')

/Users/ivanandres/SageStuff/sage-5.10/local/lib/python2.7/site-packages/sage/interfaces/r.pyc in library(self, library_name)
    592         # try hard to parse the message string in a locale-independent way
    593         if ' library(' in ret:       # locale-independent key-word
--> 594             raise ImportError, "%s"%ret
    595         else:
    596             try:

ImportError: Loading required package: Hmisc
Loading required package: survival
Loading required package: splines
Loading required package: Formula
Hmisc library by Frank E Harrell Jr

Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
to see overall documentation.


Attaching package: ‘Hmisc’

The following object(s) are masked from ‘package:survival’:

    untangle.specials

The following object(s) are masked from ‘package:base’:

    format.pval, round.POSIXt, trunc.POSIXt, units

Component: interfaces

Keywords: R, latex

Issue created by migration from https://trac.sagemath.org/ticket/15068

@gvol gvol added this to the sage-6.1 milestone Aug 20, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants