我正在尝试创建一个表(包含在MSFT Word表中),如下所示:
https://github.com/dcomtois/summarytools
3 - descr():描述性单变量统计
然而,
descr(iris, style = "rmarkdown")
style = "rmarkdown" is actually set as an st_options() - see below
如文中所示,不会在文档中创建后面的表。
view(descr(iris, style = "rmarkdown"))
是否在文档中创建了表格 - 如下所示。
view(descr(iris), "browser")
print(descr(iris), "browser")
view(descr(iris), "viewer")
print(descr(iris), "viewer")
下面以“使用带有knitr的pander”的形式创建表格(参见:http://rapporter.github.io/pander/knitr.html)
view(descr(iris), "pander")
print(descr(iris), "pander")
我可以告诉(在这一点上),我需要学习knitr(https://yihui.name/knitr/) - 研究它。
过于冗长的风险,这是我的“环境”:
R version 3.5.1 (2018-07-02) -- "Feather Spray" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) library(summarytools) library(dplyr) library(data.table) library(pander) library(knitr) library(rmarkdown)
<<<<<<在开始时采购
st_options(bootstrap.css = FALSE, # Already part of the theme so no need for it
plain.ascii = FALSE, # One of the essential settings
style = "rmarkdown", # Idem.
dfSummary.silent = TRUE, # Suppresses messages about temporary files
footnote = NA, # Keeping the results minimalistic
subtitle.emphasis = FALSE) # For the vignette theme, this gives much better results.
st_css()
library(knitr)
opts_chunk$set(comment = NA, prompt = FALSE, cache = FALSE, echo = TRUE, results = 'asis')
library(tables)
要使用knitr从rmarkdown打印summarytools对象,您有两个选择:
style = "rmarkdown"
和plain.ascii = FALSE
来使用降价式输出,你使用st_options()
正确地做了。 knitr chunk选项results
需要设置为“asis”:
```{r, results='asis'}
descr(iris, style = "rmarkdown", plain.ascii = FALSE)
```
由于您已全局设置样式和plain.ascii选项,因此可以省略函数调用中的那些选项。```{r, results='asis'}
print(descr(iris), method = "render")
```
使用以下块选项将css包含在文档顶部的块中也是一个非常好的主意:
```{r, results='asis', echo=FALSE}
st_css()
```
有关更多信息和示例,请参阅this vignette。
使用view()
打开的选项卡实际上并不打算打印或选择。你的意思是在纸上打印出来吗?这不是R的真正含义。尝试将数据导出到csv文件或其他内容。
write.csv(MyData, "My data file.csv")