| rk.print {rkward} | R Documentation |
Various utilty functions which can be used to print or export R objects to
the (html) output file. The output file can be accessed from Windows -> Show
Output. Basically, these functions along with the ones described in
rk.get.label, rk.get.tempfile.name, and
rk.graph.on can be used to create a HTML report.
rk.print(x, ...) rk.print.code(code) rk.header(title, parameters = list(), level = 1, toc = NULL) rk.results(x, titles = NULL, print.rownames) rk.print.literal(x) rk.describe.alternative(x)
x |
any R object to be printed/exported. A suitable list in case of
|
code |
a character vector (single string) of R code |
title |
a string, used as a header for the html output |
parameters |
a list, preferably named, giving a list of "parameters" to be printed to the output |
level |
an integer, header level. For example, |
toc |
If |
titles |
a character vector, giving the column headers for a html table. |
print.rownames |
controls printing of rownames. TRUE to force printing, FALSE to suppress printing, omitted (default) to print rownames, unless they are plain row numbers. |
rk.print prints/exports the given object to the output (html) file
using the HTML function. This requires the R2HTML
package. Additional arguments in ... are passed on to
HTML.
rk.print.literal prints/exports the given object using a
paste(x, collapse="\n") construct to the output (html) file.
rk.print.code applies syntax highlighting to the given code string,
and writes it to the output (html) file.
rk.header prints a header / caption, possibly with parameters, to the
output file. See example.
rk.results is similar to rk.print but prints in a more
tabulated fashion. This has been implemented only for certain types of
x: tables, lists (or data.frames), and vectors. See example.
rk.describe.alternatives describes the alternative (H1) hypothesis of
a htest. This is similar to stats:::print.htext and makes
sense only when x$alternatives exists.
rk.describe.alternatives returns a string while all other
functions return NULL, invisibly.
Thomas Friedrichsmeier rkward-devel@kde.org
HTML, rk.get.output.html.file,
rk.get.description, rk.call.plugin,
rkward://page/rkward_output
require (rkward)
require (R2HTML)
## see the output: Windows->Show Output
## stolen from the two-sample t-test plugin ;)
local({
x1 <- rnorm (100)
x2 <- rnorm (100, 2)
nm <- rk.get.description (x1,x2)
result <- t.test (x1, x2, alternative="less")
rk.print.code ("result <- t.test (x1, x2, alternative=\"less\")")
rk.header (result$method,
parameters=list ("Comparing", paste (nm[1], "against", nm[2]),
"H1", rk.describe.alternative (result),
"Equal variances", "not assumed"))
rk.print.literal ("Raw data (first few rows):")
rk.print (head (cbind (x1,x2)), align = "left")
rk.print.literal ("Test results:")
rk.results (list (
'Variable Name'=nm,
'estimated mean'=result$estimate,
'degrees of freedom'=result$parameter,
t=result$statistic,
p=result$p.value,
'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
'confidence interval of difference'=result$conf.int ))
})