你可以尝试一下我这个非常年轻的软件包, 名称是pander , 试图用 打印R对象, http://johnmacfarlane.net/pandoc/"rel="noreferr">pandoc 标记格式。
懒惰的例子:
> 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 |
+------+------+------+
我只是在做一些功能, 产生其他的表语法, 比如“简单表格”或“多线表格”(见Pandocs readme)。
P. S.:
you could also export this table easily to HTML (besides other formats like docx, odt etc.) with the (not yet documented) Pandoc
reference class like:
> myReport <- Pandoc$new()
> myReport$add(x)
> myReport
Anonymous s 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.
P.S.第二:您也可以 < a href=" http://cran.r-project.org/web/packages/brew/index.html" rel="noreferr"\\code>brew (类似 sweave) 一份包含 Pandoc.brew
的文本文件, 它会自动转换您的
> 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)
# Title
A nice matrix:
+------+------+------+
| | M | F |
+------+------+------+
| Good | 23 | 17 |
+------+------+------+
| Bad | 23 | 4 |
+------+------+------+
Bye-bye!