Skip to content

Sweave/ESS-like tools for HTML

7 messages · Sean Davis, Tom Short, Duncan Temple Lang +3 more

#
My university provides me with a powerful course management system for
the courses that I teach.  Among other things I can create a wiki for
the course, which is very convenient for cross-linking different bits
of the course.

Naturally I use R extensively in my teaching and I want to incorporate
R code, output and graphics in such a wiki.  If I were producing LaTeX
sources instead of HTML sources I create .Rnw files for Sweave and I
would edit them using ESS in emacs.

What options do I have for producing HTML with embedded R content and
what is a good, preferably emacs-based, way of editing the source
code?

One basic problem is trying to present mathematical expressions in HTML (see
http://www.cs.tut.fi/~jkorpela/math/) but, aside from that, there are
questions of presenting input R expressions and the corresponding
output and of incorporating graphics files produced by R.  I could try
to use latex2html or texi2html but the output from latex2html at least
would be quite inconvenient to use because it generates so many linked
files.  Once they are uploaded it would be horrible trying to get all
the links straightened out.

In a sense there are already tools for this type of output from .Rd
files.  Would it be best to use those tools or to use texinfo tools or
...?
#
Douglas Bates wrote:
I have never tried it, but have you looked into using the RweaveHTML
driver in the RHTML package for processing .Rnw files?

Sean
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Doug.

  This is probably more than you want - either to know or to use
for your specific task, but I'll throw it out there for general
information.

 I write documents using XML, specifically an extended version
of Docbook with elements for describing R concepts (e.g.
code, plot, output, function name, argument, ...).  Then,
I use XSL to transform this to either HTML, FO and on to PDF,
or to LaTeX (via db2latex).  As for processing
the R code and inserting the output into the resulting view/document,
I use the Sxslt package from within R which allows me to combine XSL
rules with those that also call R functions.
I author the documents using the nxml mode in emacs
and have some basic "gestures" for sending code from the document
to R.


Deb Nolan and I use this for creating dynamic and interactive
documents which can be transformed to HTML with embedded
controls for the reader to control the R computations
interactively.

Rather than thinking of the document as being one whose
primary purpose is to be displayed to readers,
the approach allows us to put arbitrary things into the
document as part of our work but render only the bits
we want for a particular audience, e.g. mix code,
pedagogical material, R documentation, data, code
from other languages.

The XML/Docbook-XSL-R approach is very general and flexible
with possibly "too" many degrees of freedom.  If the document is
destined only for HTML, then writing in HTML directly may be
best. The generality is useful when there are multiple targets
and one wants to extract information programmatically, e.g.
extract subsets of the code within the document such as
that in section 2, or only Matlab code.

I will be packaging up all the material we have on this soon,
so if anyone wants a copy, let me know.


  D.
Douglas Bates wrote:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHFRgR9p/Jzwa2QP4RAi2vAJ0S+Mnbjvt6z9pe1kPoIxHeaaZQkACggHOL
GflkuedfvPVQfm6fayigGK0=
=4fKz
-----END PGP SIGNATURE-----
#
Hi Duncan,

your approach looks _quite_ useful to me!
I'm a bit afraid it will be a very hard jump to get on that tool,
but riding it must be fun.

Yes, I'm interested!

Detlef

On Wed, 17 Oct 2007 08:59:13 +1300
Duncan Temple Lang <duncan at wald.ucdavis.edu> wrote:

            

  
    
1 day later
#
Tom Short-2 wrote:
A couple of other bits of information:
(1) I started writing a LaTeX-to-Rwiki translator,
anyone who wants to try it should contact me.
(It sounds, though, as though the wiki that Doug
Bates is going to use accepts HTML rather than
the Rwiki format?

(2) I have trouble getting through to Ian Hutchinson's
web site to get tth.  If you do get there, check out
ttm (TeX-to-MathML) as well.

  The SGML approach does seem like the wave of
the future, but in the meanwhile TeX/tth works well
for me.

  Ben Bolker
1 day later
#
On 10/18/07, Ben Bolker <bolker at ufl.edu> wrote:

            
I found the links that Tom sent to be very helpful and did install
both the tth and  tex4ht Debian packages.

Both approaches are interesting but there are some inherent
limitations to HTML and the course management system that are
difficult to overcome.  I haven't found a way to include an expression
like $\bar{x}$ without resorting to images and the course management
system goes to great lengths to hide the file hierarchy so including
an image in part of the wiki is difficult.

Perhaps it is better if I create stand-alone PDF documents but then
linking becomes difficult.