[R] RweaveHTML (R2HTML) Help

David Hajage dhajage.r at gmail.com
Wed Apr 29 10:59:18 CEST 2009


Hello Derek,

Unfortunately, I can't help you with R2HTML.

But if you want to generate html output of R commands, you could also try ascii
package <http://eusebe.github.com/ascii/> (available on CRAN).

Here an example file ("example.Rnw", with asciidoc
<http://www.methods.co.nz/asciidoc>markup) :

Example
=======
:Author:    Your Name
:Email:     name at whatever.com

<<>>=
data(iris)
summary(iris)
@

Then, you can use RweaveAsciidoc driver :

> library(ascii)
Le chargement a nécessité le package : proto
> Sweave("example.Rnw", RweaveAsciidoc)
Writing to file example.txt
Processing code chunks ...
 1 : echo term verbatim

You can now run asciidoc on 'example.txt'

And then use asciidoc to generate your html file (see asciidoc
homepage<http://www.methods.co.nz/asciidoc>for installation and use).

asciidoc example.txt

You'll find the html file produced in attachement.

Best.

david

2009/4/29 Derek Ogle <DOgle at northland.edu>

> I have found Sweave() to be great for producing PDF documents.  I have
> been experimenting with RweaveHTML (from the R2HTML) package and have
> had moderate success.  My main issue has been that I simply want the R
> output to be shown verbatim in the HTML document but RweaveHTML tends to
> convert most output to a table, for example.  So, is there a way to
> force the RweaveHTML driver to simply provide the output of a function
> exactly as it would appear in the R console window?  Thanks in advance
> for any help.
>
>
>
> A minimal reproducible example of my .rnw file is below ...
>
>
>
> <html>
>
> <body>
>
> <p>This is an example</p>
>
> <<>>=
>
> data(iris)
>
> summary(iris)
>
> @
>
> </body>
>
> </html>
>
>
>
> .... which if I saved as test.rnw I would use ...
>
>
>
> library(R2HTML)
>
> sweave(test.rnw,driver=RweaveHTML())
>
>
>
> ... which will produce test.html which looks like ...
>
>
>
> <html>
>
>
>
> <link rel=stylesheet type=text/css href=R2HTML.css><body>
>
> <p>This is an example</p>
>
> <!-- begin{Schunk} !-->
>
> <!-- begin{Sinput} !-->
>
> <p><xmp class=command>> data(iris)</xmp></p>
>
>
>
> <p><xmp class=command>> summary(iris)</xmp></p>
>
>
>
> <!-- end{Sinput} !-->
>
> <p align= center >
>
> <table cellspacing=0 border=1><caption align=bottom
> class=captiondataframe></caption><tr><td>
>
>                <table border=0 class=dataframe>
>
>                <tbody> <tr class= firstline > <th></th><th>
> Sepal.Length</th><th> Sepal.Width</th><th> Petal.Length</th><th>
> Petal.Width</th><th>      Species</th> </tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>Min.   :4.300
> </td><td class=cellinside>Min.   :2.000  </td><td class=cellinside>Min.
> :1.000  </td><td class=cellinside>Min.   :0.100  </td><td
> class=cellinside>setosa    :50  </td></tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>1st Qu.:5.100
> </td><td class=cellinside>1st Qu.:2.800  </td><td class=cellinside>1st
> Qu.:1.600  </td><td class=cellinside>1st Qu.:0.300  </td><td
> class=cellinside>versicolor:50  </td></tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>Median :5.800
> </td><td class=cellinside>Median :3.000  </td><td
> class=cellinside>Median :4.350  </td><td class=cellinside>Median :1.300
> </td><td class=cellinside>virginica :50  </td></tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>Mean   :5.843
> </td><td class=cellinside>Mean   :3.057  </td><td class=cellinside>Mean
> :3.758  </td><td class=cellinside>Mean   :1.199  </td><td
> class=cellinside>NA             </td></tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>3rd Qu.:6.400
> </td><td class=cellinside>3rd Qu.:3.300  </td><td class=cellinside>3rd
> Qu.:5.100  </td><td class=cellinside>3rd Qu.:1.800  </td><td
> class=cellinside>NA             </td></tr>
>
>  <tr><td class=firstcolumn></td><td class=cellinside>Max.   :7.900
> </td><td class=cellinside>Max.   :4.400  </td><td class=cellinside>Max.
> :6.900  </td><td class=cellinside>Max.   :2.500  </td><td
> class=cellinside>NA             </td></tr>
>
>
>
>                </tbody>
>
> </table>
>
>  </td></table>
>
>  <br>
>
>
>
> <!--\end{Schunk}!-->
>
>
>
> </body>
>
> </html>
>
>
>
>
>
>
>
> Session Info
>
> R version 2.8.0 (2008-10-20)
>
> i386-pc-mingw32
>
>
>
> locale:
>
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
>
>
> attached base packages:
>
> [1] stats     graphics  grDevices datasets  tcltk     utils     methods
> base
>
>
>
> other attached packages:
>
>  [1] pda_1.2-3          MASS_7.2-46        lme4_0.999375-28
> Matrix_0.999375-22 lattice_0.17-20    car_1.2-12         NCStats_0.1-1
>
>
>  [8] sciplot_1.0-4      plotrix_2.5-4      nortest_1.0
> svSocket_0.9-5     TinnR_1.0.2        R2HTML_1.59        Hmisc_3.5-2
>
>
>
>
> loaded via a namespace (and not attached):
>
> [1] cluster_1.11.12   gdata_2.4.2       gplots_2.6.0      grid_2.8.0
> gtools_2.5.0-1    svMisc_0.9-5      TeachingDemos_2.3 tools_2.8.0
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example.html
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090429/1407cf5d/attachment-0002.pl>


More information about the R-help mailing list