微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在flexdashboard中创建js复选框? ShinyTree不起作用R,有光泽

如何解决如何在flexdashboard中创建js复选框? ShinyTree不起作用R,有光泽

我在flexdashboard中使用shinytree有问题。在常规的闪亮应用程序中效果很好:

library(shiny)
library(shinytree)
server <- function(input,output) {
  
  output$tree <- renderTree({
    opciones = list('All'= list( 
      'Human' =  structure(list('OP1'='OP1','OP2'='OP2'),stopened=TRUE),'Mouse' =  structure(list('OP3'='OP3'),stopened=TRUE)))
    attr(opciones[[1]],"stopened")=TRUE
    opciones
  })
}

ui <- fluidPage(
  shinytree("tree",checkBox = "TRUE")
)

shinyApp(ui = ui,server = server)

但是,当我在Flexdashboard中使用它时,它将返回一个空选项卡(请参见此文件https://mega.nz/file/DCozwIiJ#ttcBe581FPfhINVoczfBvaXhgRlXwVSu-wd2JhXTEEY

您是否知道为什么会发生这种情况以及如何在flexdashboard中创建js树复选框?

解决方法

jsTreeR软件包可以做的比shinyTree软件包还要多。它可以与flexdashboard一起正常工作:

enter image description here

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---

```{r setup,include=FALSE}
library(flexdashboard)
library(shiny)
library(jsTreeR)
```

```{r}
nodes <- list(
  list(
    text = "RootA",data = list(value = 999),icon = "far fa-moon red",children = list(
      list(
        text = "ChildA1",icon = "fa fa-leaf green"
      ),list(
        text = "ChildA2",icon = "fa fa-leaf green"
      )
    )
  ),list(
    text = "RootB",children = list(
      list(
        text = "ChildB1",list(
        text = "ChildB2",icon = "fa fa-leaf green"
      )
    )
  )
)
output[["jstree"]] <- renderJstree({
  jstree(nodes,dragAndDrop = TRUE,checkboxes = TRUE,theme = "proton")
})
output[["treeSelected"]] <- renderPrint({
  input[["jstree_selected"]]
})
```


Column {data-width=400}
-----------------------------------------------------------------------

### Checkbox tree

```{r}
jstreeOutput("jstree")
```

Column {data-width=400}
-----------------------------------------------------------------------

### Selected nodes

```{r}
verbatimTextOutput("treeSelected")
```

### Chart C

```{r}

```

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。