Rオブジェクトをpandocマークダウン形式で印刷しようとするpanderという名前の、開発が進んでいる私の本当に若いパッケージを試してみてください。
怠惰な例:
> 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 |
+------+------+------+
「単純なテーブル」や「複数行のテーブル」などの他のテーブル構文を生成するいくつかの関数に取り組んでいます(Pandocのreadmeを参照)。
PS:次のような(まだ文書化されていない)Pandoc
参照クラスを使用して、このテーブルをHTMLに簡単にエクスポートすることもできます(docx、odtなどの他の形式を除く)。
> 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.
PS 2番目:タグを内部RオブジェクトからPandocマークダウン形式に自動変換するbrew
テキストドキュメントを(スウィーブのように)使用することもできます。短い例(もちろん、これはファイル入力でも機能しますが、今はR文字ベクトルだけです):Pandoc.brew
<%=...%>
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!