我试图隐藏格式正确的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>
答案 0 :(得分:0)
在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>