如果我想在R中为PDF很好地打印sessionInfo,我可以使用

toLatex(sessionInfo())

似乎应该为rmarkdown提供类似的选项以HTML形式呈现,但是我在这里或Rdocumentation上找不到它。在重新发明轮子之前,以为我会问是否等于
toMarkdown(sessionInfo())

已经存在。

最佳答案

尝试pander,它是general method to do the R->markdown conversion:

> pander(sessionInfo())
**R version 3.2.1 (2015-06-18)**

**Platform:** x86_64-unknown-linux-gnu (64-bit)

**locale:**
_LC_CTYPE=hu_HU.utf8_, _LC_NUMERIC=C_, _LC_TIME=hu_HU.utf8_, _LC_COLLATE=C_, _LC_MONETARY=hu_HU.utf8_, _LC_MESSAGES=hu_HU.utf8_, _LC_PAPER=hu_HU.utf8_, _LC_NAME=C_, _LC_ADDRESS=C_, _LC_TELEPHONE=C_, _LC_MEASUREMENT=hu_HU.utf8_ and _LC_IDENTIFICATION=C_

**attached base packages:**
_stats_, _graphics_, _grDevices_, _utils_, _datasets_, _methods_ and _base_

**other attached packages:**
pander(v.0.5.3)

**loaded via a namespace (and not attached):**
_tools(v.3.2.1)_, _Rcpp(v.0.12.1)_ and _digest(v.0.6.8)_

或以长格式:
> pander(sessionInfo(), compact = FALSE)
**R version 3.2.1 (2015-06-18)**

**Platform:** x86_64-unknown-linux-gnu (64-bit)

**locale:**
_LC_CTYPE=hu_HU.utf8_, _LC_NUMERIC=C_, _LC_TIME=hu_HU.utf8_, _LC_COLLATE=C_, _LC_MONETARY=hu_HU.utf8_, _LC_MESSAGES=hu_HU.utf8_, _LC_PAPER=hu_HU.utf8_, _LC_NAME=C_, _LC_ADDRESS=C_, _LC_TELEPHONE=C_, _LC_MEASUREMENT=hu_HU.utf8_ and _LC_IDENTIFICATION=C_

**attached base packages:**

* stats
* graphics
* grDevices
* utils
* datasets
* methods
* base


**other attached packages:**

* pander(v.0.5.3)


**loaded via a namespace (and not attached):**

* tools(v.3.2.1)
* Rcpp(v.0.12.1)
* digest(v.0.6.8)

产生以下HTML:

r - 如何在rmarkdown中格式化sessionInfo()?-LMLPHP

关于r - 如何在rmarkdown中格式化sessionInfo()?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33156946/

10-12 14:59