嵌套数据框交互式 R markdown
Nested dataframes interactive R markdown
我正在尝试根据一些分析创建一份报告,但它导致与 'master output table' 中的每个 table 相关的 table 过多。
因此,我一直在尝试将每个 table 嵌套在其适当的行中,从而在 df.
中创建一个嵌套的 df-column
这是我正在尝试创建的示例,在 Rstudio 查看器中它看起来正是我想要的。用户可以点击每个嵌套的 df 来展开它。
[![在此处输入图片描述][1]][1]
我试过 tibbles、reactable、DT、Kable 和 data.table,但它们似乎都呈现出不同的东西(要么不是可扩展的信息,例如 ,要么只是打印所有内容这会创建一个无法使用的报告)
我的下一个选择是制作一个闪亮的应用程序,但它们的输出无法发送给用户,所以我宁愿避免这种情况。
标题:"test"
输出:html_document
knitr::opts_chunk$set(echo = TRUE)
library("tidyverse")
library("rlist")
library(reactable)
library(tibble)
json文件"br08001.json"来自这里
https://www.genome.jp/kegg-bin/get_htext?br08001+C00186 - 'Download json'
KEGG_compounds <- jsonlite::fromJSON('br08001.json', flatten = TRUE)
df <- KEGG_compounds[[2]]
tibble::as_tibble(df)
_____________________ @Daniel 建议的改进 Jachetta____________
---
title: "Test"
author: "..."
date: "`r Sys.Date()`"
output:
html_document
---
```{r}
KEGG_compounds <- jsonlite::fromJSON('C:/Users/skourtis/Downloads/br08001.json', flatten = TRUE)[[2]]
DT::datatable(KEGG_compounds)
```
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName"> Organic Acids </button>
<div id="BlockName" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[1]])
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName1"> Lipids </button>
<div id="BlockName1" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[2]])
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName2"> Carbohydrates </button>
<div id="BlockName2" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[3]])
```
</div>
这并没有真正的图形方面,但它为您提供了每个数据集名称的按钮。你能帮我访问你的tibbles里面的tibbles吗,我可以修改我的草稿答案。
---
title: "Test"
author: "..."
date: "`r Sys.Date()`"
output:
html_document
---
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName"> iris </button>
<div id="BlockName" class="collapse">
```{r}
print(iris)
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName1"> Cars </button>
<div id="BlockName1" class="collapse">
```{r}
print(mtcars)
```
</div>
我正在尝试根据一些分析创建一份报告,但它导致与 'master output table' 中的每个 table 相关的 table 过多。 因此,我一直在尝试将每个 table 嵌套在其适当的行中,从而在 df.
中创建一个嵌套的 df-column这是我正在尝试创建的示例,在 Rstudio 查看器中它看起来正是我想要的。用户可以点击每个嵌套的 df 来展开它。
[![在此处输入图片描述][1]][1]
我试过 tibbles、reactable、DT、Kable 和 data.table,但它们似乎都呈现出不同的东西(要么不是可扩展的信息,例如
我的下一个选择是制作一个闪亮的应用程序,但它们的输出无法发送给用户,所以我宁愿避免这种情况。
标题:"test"
输出:html_document
knitr::opts_chunk$set(echo = TRUE)
library("tidyverse")
library("rlist")
library(reactable)
library(tibble)
json文件"br08001.json"来自这里 https://www.genome.jp/kegg-bin/get_htext?br08001+C00186 - 'Download json'
KEGG_compounds <- jsonlite::fromJSON('br08001.json', flatten = TRUE)
df <- KEGG_compounds[[2]]
tibble::as_tibble(df)
_____________________ @Daniel 建议的改进 Jachetta____________
---
title: "Test"
author: "..."
date: "`r Sys.Date()`"
output:
html_document
---
```{r}
KEGG_compounds <- jsonlite::fromJSON('C:/Users/skourtis/Downloads/br08001.json', flatten = TRUE)[[2]]
DT::datatable(KEGG_compounds)
```
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName"> Organic Acids </button>
<div id="BlockName" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[1]])
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName1"> Lipids </button>
<div id="BlockName1" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[2]])
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName2"> Carbohydrates </button>
<div id="BlockName2" class="collapse">
```{r}
DT::datatable(KEGG_compounds[[2]][[3]])
```
</div>
这并没有真正的图形方面,但它为您提供了每个数据集名称的按钮。你能帮我访问你的tibbles里面的tibbles吗,我可以修改我的草稿答案。
---
title: "Test"
author: "..."
date: "`r Sys.Date()`"
output:
html_document
---
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName"> iris </button>
<div id="BlockName" class="collapse">
```{r}
print(iris)
```
</div>
<button class="btn btn-primary" data-toggle="collapse" data-target="#BlockName1"> Cars </button>
<div id="BlockName1" class="collapse">
```{r}
print(mtcars)
```
</div>