[R] Rpad - avoid removal of manually created html-tags in R chunk

Martin Gartner h0351427 at wu-wien.ac.at
Sat Jun 6 14:31:52 CEST 2009


Martin Gartner wrote:
> Dear Rpad-users,
>
> currently I am setting up a web page using Rpad (www.rpad.org). But I 
> have a problem with generating dynamic html-output in the Rpad chunk. 
> Here an example of my problem:
>
> I have the following index.html file:
>
> <html>
>  <head>
>    <title>example</title>
>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>    <script type="text/javascript" src="gui/Rpad.js"></script>
>  </head>
>  <body>
>    <pre dojoType="Rpad" rpadRun="init" rpadOutput="html" 
> rpadHideSource="true">
>      x <- 
> "<table><tr><th>A</th><th>B</th></tr><td>a</td><td>b</td></table>"
>    </pre>
>  </body>
> </html>
>
> If I run Rpad("index.html") in the local server mode and when I turn 
> to my Rgui, then the object "x" looks like "ABab", i.e. all my 
> html-tags are removed within the R-chunk.
>
> I know that I can avoid this with nested "HtmlTree"s, e.g.
>
> H("table", H("tr", H("th", "A"), H("th", "B")), H("tr", H("td", "a"), 
> H("td", "b")))
>
> but as I have to produce html-output of a large dataframe (100 rows 
> and 6 colums), the nesting takes too much time (because every cell 
> element might have conditional formatting and I have to check each 
> element) and I think it would be faster with pasting all html-code 
> manually into a character-object and printing this object as html. But 
> trying this I have the above mentioned problem.
>
> Can anybody help me? If anybody knows a solution, how I can avoid, 
> that the html-tags are removed from my "x" (see example above), I 
> think, I can produce my output very fast.
>
> Thanks and best regards,
> Martin
>
> ______________________________________________
> 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.
>
>
Hi everybody,

I already got the solution. I have to use the encoded characters for the tags ... 

<html>
  <head>
    <title>GUI Examples</title>
    <script type="text/javascript">
        rpadConfig = {
            gui: "alternate",
            rpadHideSource: true
        };
    </script>
    <script type="text/javascript" src="gui/Rpad.js"></script>
  </head>
  <body>
&#60 &#62
    <pre dojoType="Rpad" rpadRun="init" rpadOutput="html" rpadHideSource="true">
      x <- "&#60table border='1'&#62&#60tr&#62&#60th&#62A&#60&#47th&#62&#60th&#62B&#60&#47th&#62&#60&#47tr&#62&#60td&#62A&#60&#47td&#62&#60td&#62B&#60&#47td&#62&#60&#47table&#62"
     cat(x)
  </body>
</html>

Best regards,
Martin




More information about the R-help mailing list