如何在 rmarkdown 中格式化 sessionInfo()? [英] How can I format sessionInfo() in rmarkdown?

查看:45
本文介绍了如何在 rmarkdown 中格式化 sessionInfo()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

toLatex(sessionInfo())

rmarkdown 似乎应该有一个类似的选项来呈现在 HTML 中,但我在此处或 Rdocumentation 上找不到它.在重新发明轮子之前,我想我会问是否相当于

toMarkdown(sessionInfo())

已经存在.

解决方案

尝试 pander,这是一个

If I want to nicely print my sessionInfo in R for a PDF, I can just use

toLatex(sessionInfo())

It seems like there should be a similar option for rmarkdown to render in HTML, but I can't find it here or on Rdocumentation. Before re-inventing the wheel, thought I'd ask if the equivalent of

toMarkdown(sessionInfo()) 

already exists.

解决方案

Try pander, which is a 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)_

Or in the long form:

> 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) 

Resulting in the following HTML:

这篇关于如何在 rmarkdown 中格式化 sessionInfo()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆