#15068: Typesetting of R objects is problematic
--------------------------+-----------------------------
Reporter: iandrus | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-5.12
Component: interfaces | Keywords: R, latex
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
--------------------------+-----------------------------
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
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/15068>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.