How can I format sessionInfo() in rmarkdown?

后端 未结 2 573
广开言路
广开言路 2021-02-08 12:46

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 f

2条回答
  •  孤城傲影
    2021-02-08 13:19

    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:

提交回复
热议问题