ascii is a R package for writing asciidoc, txt2tags, reStructuredText, org or textile documents with embeded R code.
<<>>=
x <- matrix(1:4, 2, 2)
x
@
gives in the final document:
> x <- matrix(1:4, 2, 2)
> x
[,1] [,2]
[1,] 1 3
[2,] 2 4
<<echo = FALSE, results = ascii>>=
ascii(x)
@
gives:
1.00 | 3.00 |
2.00 | 4.00 |
The same with some options:
> ascii(x, caption = "A simple matrix", width = 50, digits = 0, align = c("c",
<code>+ "r"), style = matrix(c("d", "s", "e", "m"), 2, 2), lgroup = "group 1", </code>
<code>+ tgroup = "group 2")</code>
A simple matrix
group 2 | ||
---|---|---|
group 1 | 1 | 3 |
2 | 4 |
<<echo = FALSE, results = ascii>>=
y <- summary(with(esoph, table(alcgp, agegp)))
ascii(y, caption = "A simple list")
@
.A simple list
ascii provides:
ascii()
. It creates a plain text representations of many R objects.Sweave
drivers: RweaveAsciidoc()
, RweaveT2t()
, RweaveReST()
, RweaveOrg()
and RweaveTextile()
.Sweave
drivers: weaverAsciidoc()
, weaverT2t()
, weaverReST()
, weaverOrg()
and weaverTextile()
.Sweave
drivers: cacheSweaveAsciidoc()
, cacheSweaveT2t()
, cacheSweaveReST()
, cacheSweaveOrg()
and cacheSweaveTextile()
.Sweave()
named Asciidoc()
, T2t()
, ReST()
, Org()
and Textile()
.ascii provides methods for:
> methods(ascii)
[1] ascii.anova* ascii.aov* ascii.aovlist*
[4] ascii.cast_df* ascii.character* ascii.coxph*
[7] ascii.CrossTable* ascii.data.frame* ascii.default*
[10] ascii.density* ascii.describe* ascii.describe.single*
[13] ascii.factor* ascii.freqtable* ascii.ftable*
[16] ascii.glm* ascii.htest* ascii.integer*
[19] ascii.list* ascii.lm* ascii.matrix*
[22] ascii.meanscomp* ascii.numeric* ascii.packageDescription*
[25] ascii.prcomp* ascii.sessionInfo* ascii.simple.list*
[28] ascii.smooth.spline* ascii.summary.aov* ascii.summary.aovlist*
[31] ascii.summary.glm* ascii.summary.lm* ascii.summary.prcomp*
[34] ascii.summary.survfit* ascii.summary.table* ascii.survdiff*
[37] ascii.survfit* ascii.table* ascii.ts*
[40] ascii.zoo*
Non-visible functions are asterisked
Charlie Geyer created a demonstration of Sweave entitled available at his Sweave page. A version using textile is available here.