You can try my really young package under heavy development called pander , which is trying to print R-objects in pandoc marking format.
Lazy example:
> x <- matrix(c("", "M", "F", "Good", "23", "17", "Bad", "23", "4"), nrow=3, byrow=TRUE) > pandoc(x) +------+------+------+ | | M | F | +------+------+------+ | Good | 23 | 17 | +------+------+------+ | Bad | 23 | 4 | +------+------+------+
I'm just working on some functions, resulting in a different table syntax, such as a "simple table" or "multi-row table" (see Pandoc readme).
R. S .: you can also easily export this table to HTML (among other formats, such as docx, odt, etc.) with the Pandoc
reference class (not documented):
> myReport <- Pandoc$new() > myReport$add(x) > myReport Anonymous report ================== written by *Anonymous* at *Sun May 27 21:04:22 2012* This report holds 1 block(s). --- +------+------+------+ | | M | F | +------+------+------+ | Good | 23 | 17 | +------+------+------+ | Bad | 23 | 4 | +------+------+------+ --- Proc. time: 0.009 seconds. > myReport$format <- 'html' > myReport$export() Exported to */tmp/pander-4e9c12ff63a6.[md|html]* under 0.031 seconds.
PS secondly: you can also brew
(e.g. sweave) a text document with Pandoc.brew
, which automatically converts the tags <%=...%>
from internal R to the Pandoc markdown format. A short example (of course, this will also work with file input, now I just brew
the character vector R):
> t <- '# Title + + A nice matrix: + + <%=matrix(c("", "M", "F", "Good", "23", "17", "Bad", "23", "4"), nrow=3, byrow=TRUE)%> + + Bye-bye!' > > Pandoc.brew(text=t)