【问题标题】:RMarkdown: How to print or break large results into tabbed content (Tabs)RMarkdown:如何将大型结果打印或分解为选项卡式内容(选项卡)
【发布时间】:2021-07-28 17:36:18
【问题描述】:

假设我有这个输出

如您所见,R markdown 将结果分为 4 个部分。我想将这些结果打印到 4 个选项卡中,如下图所示:

我查看了before at this thread,但没有找到任何解决方案。谢谢

完整代码如下:

ds <- data.frame(x1=rbinom(100, 1,0.5),x2=rbinom(100, 1,0.5),x3=rbinom(100, 1,0.5))
psych::alpha(ds)

【问题讨论】:

    标签: r tabs r-markdown


    【解决方案1】:

    从概念上讲,你已经在那里了。想想你想如何在你计划的标签集上分割/分布你的输出。

    我恢复到iris 数据集,因为我不想安装{psych} 包。但是从图像中您可以获得数据帧。
    我通过子集虹膜来模拟不同的数据帧,例如想想 df1

    您可以在标签集部分内以标准Rmd 方式放置不同的对象(数据框)、可视化/绘图或文本。

    ---
    title: "Tabed output"
    author: "Demo-Author"
    date: "28/07/2021"
    output: html_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    
    library(magrittr)  # for using the pipe
    
    df <- iris
    ```
    
    ## title {.tabset .tabset-fade}
    
    This is content above tabbed region.    
    
    The next level heading will start the tabset where you can place the content
    
    ### tab 1 
    
    tab content 1 commentary
    
    ```{r}
    df[1:10,] %>% knitr::kable()
    ```
    
    
    ### tab 2
    
    tab content 2 commentary above a table.
    
    ```{r}
    df[11:25,] %>% knitr::kable()
    ```
    
    ##
    
    content below tabbed region and your further Rmd story!
    

    ...会给你以下输出(我坚持2个标签),但你会明白原理。

    【讨论】:

      猜你喜欢
      • 2016-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多