out outputs the argument as-is (also works for objects that are intended for web output)

oprint outputs the result of verbatim print call

otable constructs a table

ohead creates a header

oclear clears (by discarding existing content) the output buffer and/or headers

out(..., sep = "", eol = "\n")
oprint(..., sep = "\n", escape = TRUE)
otable(..., tab = "", tr = "", cs = "</td><td>", escape = TRUE)
ohead(..., level = 3, escape = TRUE)
oclear(output=TRUE, headers=FALSE)

Arguments

...

entries to output or print

sep

separator string

eol

end of line separator

escape

if TRUE special HTML characters are escaped in inner text (via `FastRWeb:::htmlEscape`), if FALSE the strings are passed without modification. It can also be a function taking exactly one argument that is expected to perform the escaping.

tab

additional attributes for table HTML tag

tr

additional attibutes for table row (tr) HTML tag

cs

column separator

level

level of the header (1 is the topmost)

output

logical, if TRUE then the output is cleared

headers

logical, if TRUE then the headers are cleared

Value

All functions returns the full document as constructed so far

Details

The output functions enable the run function to build the result object gradually as opposed to returing just one WebResult object at the end.

The output functions above manipulate an internal buffer that collects output and uses done to contruct the final WebResult object. It is analogous to using print to create output in R scripts as they proceed. However, due to the fact that print output is generally unsuitable as HTML output, the output function here process the output such that the result is a HTML document. Special HTML characters `<`, `>` and `&` are escaped in the inner text (not in tags) if escape=TRUE in functions that provide that argument.

NOTE: It is important to remember that the output is collected in a buffer, so in order to actually create the output, do not forget to use return(done()) when leaving the run function to use that content!

See also

Examples

  run <- function(...) {
    ohead("My Table", level=2)
    d <- data.frame(a = 1:3, b = c("foo", "bar", "foobar"))
    otable(d)
    out("<p><b>Verbatim R output:</b><br>")
    oprint(str(d))
    done()
  }