How can I use vtree package in shiny? The desired plot is not appearing when trying to render it from serverside. My code:
library(shiny)
library(vtree)
# Define UI ----
ui <- pageWithSidebar(
# App title ----
headerPanel("Cyl vtree"),
# Sidebar panel for inputs ----
sidebarPanel(),
# Main panel for displaying outputs ----
mainPanel(
plotOutput("plot1")
)
)
# Define server logic to plot ----
server <- function(input, output) {
output$plot1 <- renderPlot({
vtree(mtcars, "cyl")
})
}
shinyApp(ui, server)
This is a HTML widget. You have to use the function renderVtree
and vtreeOutput
.
library(shiny)
library(vtree)
# Define UI ----
ui <- pageWithSidebar(
# App title ----
headerPanel("Cyl vtree"),
# Sidebar panel for inputs ----
sidebarPanel(),
# Main panel for displaying outputs ----
mainPanel(
vtreeOutput("VTREE")
)
)
# Define server logic to plot ----
server <- function(input, output) {
output[["VTREE"]] <- renderVtree({
vtree(mtcars, "cyl")
})
}
shinyApp(ui, server)