【问题标题】:How to hide correctly formatted knitr::kable() in html-documents?如何在 html 文档中隐藏格式正确的 knitr::kable()?
【发布时间】:2016-04-14 10:57:58
【问题描述】:

我试图隐藏格式正确的 knitr::kable() 表。不隐藏它们看起来不错......但如果我显示已经隐藏的表格,它们会显示为普通文本......到目前为止这是我的代码:

---
title: "Test-Tabellen"
output: 
  html_document:
    theme: cerulean
    highlight: textmate
    code_folding: hide
---

```{r}
setwd("/Users/AnyName/Desktop/")
```

#####31 elements included exclusively in "Control":
<div id="BE_Genus_C.txt" style="display:none">
```{r cache=FALSE, collapse=TRUE, results='asis'}
test<-read.csv2("BE_Genus_C.txt", header=FALSE, sep="\t")
knitr::kable(test)
```
</div>
<button title="Click to show answer" type="button" onclick="if(document.getElementById('BE_Genus_C.txt') .style.display=='none') {document.getElementById('BE_Genus_C.txt') .style.display=''}else{document.getElementById('BE_Genus_C.txt') .style.display='none'}">Show/hide</button>

【问题讨论】:

    标签: html r markdown knitr


    【解决方案1】:

    只需在div 后面多加一行就够了……

    <div id="BE_Genus_C.txt" style="display:none">
    ```{r cache=FALSE, collapse=TRUE, results='asis'}
    test<-read.csv2("BE_Genus_C.txt", header=FALSE, sep="\t")
    knitr::kable(test)
    ```
    
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-27
      • 2019-10-25
      • 2017-01-08
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 2012-05-10
      • 2017-06-20
      相关资源
      最近更新 更多