dfSummary()图形未打印在html文件中

时间:2020-11-07 08:57:19

标签: r r-markdown knitr summarytools

在Rmarkdown -file的“ summarytools”包中使用dfSummary()时,尽管有st_options(plain.ascii = FALSE),我还是将摘要的Graph-部分打印为纯ascii。正确的图形显示在/ tmp-文件夹中,但未显示在html文件中。

 let array = fetchTeamData()
console.log(array)

function fetchTeamData(){
    let array
    fetch("https://api.opendota.com/api/teams")
    .then(function(response) {
        array = response.json()
    })
    return array
}

上面的代码摘要按如下方式打印:

Print

我如何获得html文件中包含的正确图形(在tmp文件夹中又漂亮又有光泽)?

2 个答案:

答案 0 :(得分:1)

我如何获得html文件中包含的正确图形(在tmp文件夹中又漂亮又有光泽)?

根据多米尼克人的vignette-“在Rmarkdown中使用summarytools的建议”:

对于dfSummary(),建议使用 grid

因此,您可以尝试使用print()函数进行跟踪:

```{r Summary, results = "asis", cache = FALSE}
base::print(summarytools::dfSummary(df_data,
                                    valid.col = FALSE,       # drop Valid column if redundant
                                    style = "grid",          # set style to “grid”
                                    plain.ascii = FALSE,
                                    graph.magnif = 0.75,     # zoom factor (max = 1) for bar plots and histograms
                                    tmp.img.dir = "./tmp"),
            dfSummary.silent  = TRUE,                        # Suppresses messages about temporary files
            bootstrap.css = FALSE)
```

或者,如果您想先声明st_options()

```{r Summary2, results = 'asis', echo = FALSE}
st_options(bootstrap.css = FALSE, 
           dfSummary.silent = TRUE)
st_css()

dfSummary(df_data, 
          valid.col = FALSE,  
          style = "grid", 
          plain.ascii = FALSE, 
          graph.magnif = 0.75, 
          tmp.img.dir = "./tmp")
```

让我们知道这是否有帮助。

答案 1 :(得分:0)

只需添加style="grid"

dfSummary(df_data, style = "grid", tmp.img.dir = "/tmp",
          valid.col = FALSE,  graph.magnif = 0.75)

文档在这一点上不够清楚,将在下一个版本中修复。