I am creating Tree View in R Shiny using shinyTree package, able to do the same. The code which has been used for server part has list creation. Now, additional requirement is to convert the dataframe into list and import the same to achieve the tree structure using renderTree.
Here is the code which I have written:
#ui part
library(shiny)
library(shinyTree) # Using shinyTree Package
# UI for application that demonstrates a Tree View
shinyUI(
pageWithSidebar(
# Application title
headerPanel("Tree View in Shiny"),
sidebarPanel(
helpText(HTML("A simple Shiny Tree example.
<hr>Created using shinyTree Package."))
),
mainPanel(
# Show a simple table.
shinyTree("tree")
)
))
#--------------------------------------------------------------------
#server part
library(shiny)
library(shinyTree)
# server logic required to generate a tree structure
shinyServer(function(input, output, session) {
output$tree <- renderTree({
**list(
Folder1 = list(File1.1 = structure("",sticon="file"), File1.2 = structure("",sticon="file")),
Folder2 = list(
Subfolder2.1 = list(File2.1.1 = structure("",sticon="file"), File2.1.2 = structure("",sticon="file")
, File2.1.3=structure("",sticon="file")),
Subfolder2.2 = list(File2.2.1 = structure("",sticon="file"), File2.2.2 = structure("",sticon="file")),
File2.3 = structure("",sticon="file")
)**
)
})
})
The star part of the code needs to be replaced with list (that has been converted using dataframe). How I can achieve the same.