multiple plot outputs R in different tabs (shinyDashboard) - r

The code currently produces the dashboard and the side panels for the plots, it also produces one plot. (which ever is called first in the final line). If anyone has any suggestions on how to produce two separate plots on two different tabs using a shiny dashboard it would be much appreciated. Tearing my hair out!
https://lot1bct.shinyapps.io/lot1bct/
My current state, minus the "fuels" tab and second plot for reference on what i'm aiming for.
The code below has the second plot code mocked up along with the additional dashboard code in the "fuels" tab which the live version does not.
## app.R ##
library(shinydashboard)
library(shiny)
library(ggplot2)
dataset <- testData
fuelData <- fuelDataCSV
tyreData <- tyreDataCSV
ui <- dashboardPage(
skin="green",
dashboardHeader(title = "Strategy Dashboard v0.1",
dropdownMenu(type = "tasks", badgeStatus = "success",
taskItem(value = 10, color = "green",
"Documentation"
),
taskItem(value = 30, color = "aqua",
"UI"
),
taskItem(value = 15, color = "yellow",
"Data Developmentt"
)
)),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Home", tabName = "home", icon = icon("home")),
menuItem("Tyres", tabName = "tyres", icon = icon("circle-o")),
menuItem("Fuels and Lubericants", tabName = "fuel", icon = icon("flask")),
menuItem("Times", tabName = "times", icon = icon("clock-o")),
menuItem("Documentation", tabName = "documentation", icon = icon("sticky-note-o")),
menuItem("Downloads", tabName = "downloads", icon = icon("download")),
# Custom CSS to hide the default logout panel
tags$head(tags$style(HTML('.shiny-server-account { display: none; }'))),
# The dynamically-generated user panel
uiOutput("userpanel")
)
),
## Header Content
## Body content
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "home",
h2("UI Tests"), p("This published version is the first test build (version 0.1).")
),
# Second tab content
tabItem(tabName = "tyres",
h2("Tyre data sets"), fluidPage(
sidebarPanel(
sliderInput('sampleSize', 'Sample Size (Laps)', min=1, max=nrow(tyreData),
value=min(20, nrow(tyreData)), step=1, round=0),
selectInput('x', 'X', names(tyreData)),
selectInput('y', 'Y', names(tyreData), names(tyreData)[[2]]),
selectInput('color', 'Color', c('None', names(tyreData))),
checkboxInput('density', 'Density'),
checkboxInput('trend', 'Trend')
),
mainPanel(
plotOutput('plotT')
)
)
),
# Third tab content
tabItem(tabName = "fuel",
h2("Fuel and Lubricant data sets"),
fluidPage(
sidebarPanel(
sliderInput('sampleSize', 'Sample Size (Laps)', min=1, max=nrow(fuelData),
value=min(20, nrow(fuelData)), step=1, round=0),
selectInput('x', 'X', names(fuelData)),
selectInput('y', 'Y', names(fuelData), names(fuelData)[[2]]),
selectInput('color', 'Color', c('None', names(fuelData))),
checkboxInput('density', 'Density'),
checkboxInput('trend', 'Trend')
),
mainPanel(
plotOutput('plotF')
)
)
),
# Fourth tab content
tabItem(tabName = "times",
h2("Times data sets")
),
# Fifth tab content
tabItem(tabName = "documentation",
h2("Documentation")
),
# Sixth tab content
tabItem(tabName = "downloads",
h2("Downloads")
)
)
)
)
tyrePlot <- function(input, output) {
tyreData <- reactive({
tyreDataCSV[sample(nrow(tyreDataCSV), input$sampleSize),]
})
output$plotF <- renderPlot({
p <- ggplot(tyreData(), aes_string(x=input$x, y=input$y)) + geom_point()
if (input$color != 'None')
p <- p + aes_string(color=input$color)
if (input$density)
p <- p + geom_density_2d()
if (input$trend)
p <- p + geom_smooth()
print(p)
}, height=700)
}
fuelPlot <- function(input, output) {
fuelData <- reactive({
fuelDataCSV[sample(nrow(fuelDataCSV), input$sampleSize),]
})
output$plotF <- renderPlot({
p <- ggplot(fuelData(), aes_string(x=input$x, y=input$y)) + geom_point()
if (input$color != 'None')
p <- p + aes_string(color=input$color)
if (input$density)
p <- p + geom_density_2d()
if (input$trend)
p <- p + geom_smooth()
print(p)
}, height=700)
}
shinyApp(ui, tyrePlot, fuelPlot)

Related

Shiny app - hide/show text comment under the plot after clicking checkbox

I want to build an app with the checkbox asking whether to show additional text comments under the figures.
I would like to display set of plots with or without an explanation - this shall be left to the user, whether they need more info or not.
Here are some dummy comments:
#info for box1:
"This is the red histogram"
#info for box2:
"This is the blue histogram"
Here is a dummy app:
library(shiny)
library(shinydashboard)
data <- rnorm(10000, mean=8, sd=1.3)
variable <- "This is the blue histogram"
shinyApp(
ui = dashboardPage(
skin = "black",
dashboardHeader(
title = "Example app",
titleWidth = 300
),
dashboardSidebar(
checkboxInput("show_comment",
label = "Show comment?",
value = FALSE)
),
dashboardBody(
box(title = "First histogram",
status= "warning",
plotOutput("plot1", height=300)
),
box(title = "Second histogram",
status= "warning",
plotOutput("plot2", height=300),
hidden(
div(id='text_div',
verbatimTextOutput("text")))
)
)
),
server = function(input, output) {
output$plot1 <- renderPlot({
hist(data, breaks=40, col="red", xlim=c(2,14), ylim=c(0,800))
})
output$plot2 <- renderPlot({
hist(data, breaks=20, col="blue", xlim=c(2,34), ylim=c(0,1000))
})
observeEvent(input$show_comment, {
toggle('text_div')
output$text <- renderText({ paste0(variable)})
})
}
)
The above code does not work properly - it displays comment no matter if the checkbox is clicked or not. I'd like to make it work, therefore seek for advice here.
I was trying to do it on my own using following hints, to no avail:
How to use shiny actionButton to show & hide text output?
This syntax is too complex for me as I am a beginner with shiny, so I was not able to troubleshoot my problem with hints from this thread:
Show and hide text in modularized shiny app based on actionButton() and shinyJS()
I also tried ths:
Hide/show outputs Shiny R
And here is the attempt of using above hint:
library(shiny)
library(shinydashboard)
data <- rnorm(10000, mean=8, sd=1.3)
variable <- "This is the blue histogram"
shinyApp(
ui = dashboardPage(
skin = "black",
dashboardHeader(
title = "Example app",
titleWidth = 300
),
dashboardSidebar(
checkboxInput("show_comment",
label = "Show comment?",
value = FALSE)
),
dashboardBody(
box(title = "First histogram",
status= "warning",
plotOutput("plot1", height=300)
),
box(title = "Second histogram",
status= "warning",
plotOutput("plot2", height=300),
renderText("text", span(variable))
)
)
),
server = function(input, output) {
output$plot1 <- renderPlot({
hist(data, breaks=40, col="red", xlim=c(2,14), ylim=c(0,800))
})
output$plot2 <- renderPlot({
hist(data, breaks=20, col="blue", xlim=c(2,34), ylim=c(0,1000))
})
observeEvent(input$show_comment, {
# every time the button is pressed, alternate between hiding and showing the plot
toggle("text")
})
}
)
I want to put the comments inside the same box, along with the plot - this is why I am trying to enclose it with the box command. However, if it is impossible - I would be glad of any other solution.
First time I use shinyjs so there might be a better approach. But as I understand it from the docs you first have to add useShinyjs() in your UI code
in order for all other shinyjs functions to work.
Second, there is no need to wrap the div for your comment in hidden(). Third, instead of using observeEvent I followed the example in ?toggle and use an observe where I add the state of your checkbox as the condition to trigger the toggle.
library(shiny)
library(shinydashboard)
library(shinyjs)
data <- rnorm(10000, mean = 8, sd = 1.3)
variable <- "This is the blue histogram"
shinyApp(
ui = dashboardPage(
skin = "black",
dashboardHeader(
title = "Example app",
titleWidth = 300
),
dashboardSidebar(
checkboxInput("show_comment",
label = "Show comment?",
value = FALSE
)
),
dashboardBody(
box(
title = "First histogram",
status = "warning",
plotOutput("plot1", height = 300)
),
box(
title = "Second histogram",
status = "warning",
plotOutput("plot2", height = 300),
div(id = "text_div",
verbatimTextOutput("text")
)
)
),
useShinyjs()
),
server = function(input, output) {
output$plot1 <- renderPlot({
hist(data, breaks = 40, col = "red", xlim = c(2, 14), ylim = c(0, 800))
})
output$plot2 <- renderPlot({
hist(data, breaks = 20, col = "blue", xlim = c(2, 34), ylim = c(0, 1000))
})
observe({
toggle(id = "text_div", condition = input$show_comment)
output$text <- renderText({
paste0(variable)
})
})
}
)
#>
#> Listening on http://127.0.0.1:7437

Cannot specify input dataset in shiny dashboard

I am trying to make a shiny dashboard. I have two datasets, and based upon the selection of the datasets figures will be generate in the tab panels. However, by default only the last dataset that has been loaded/read is selected and I cannot select the first dataset. Even though I have made it default selection.
Below is my code.
library(shinydashboard)
library(uwot)
library(DESeq2)
library(gridExtra)
library(tidyverse)
library(RColorBrewer)
library(DESeq2)
library(pheatmap)
library(DEGreport)
library(vsn)
library(RColorBrewer)
library("genefilter")
library(org.Hs.eg.db)
library(dplyr)
library(tidyverse)
library(fgsea)
library(clusterProfiler)
library(ggplot2)
set_1<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData")
set_2<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData")
data_list = list(set_1=set_1,set_2=set_2)
ui <- dashboardPage(
dashboardHeader(title = "Data Visualizer", titleWidth = 300),
dashboardSidebar(
width = 300,
sidebarMenu(
menuItem("Datasets", icon = icon("cog"),
selectInput("Datasets", "Datasets:", choices = list("sample1" = "set_1", "sample2" = "set_2"),
selected = "set_1")),
menuItem("Quality Control", tabName = "widgets", icon = icon("th")),
menuItem("Differential Genes", tabName = "widgets2", icon = icon("th")),
menuItem("Downstream", tabName = "widgets3", icon = icon("th"))
)
),
## Body content
dashboardBody(
tabItems(
# First tab content
# Second tab content
tabItem(tabName="widgets",
h2("widgets"),
plotOutput("widgets"),
),
tabItem(tabName = "widgets2",
h2("Widgets2 tab content"),
),
tabItem(tabName = "widgets3",
h2("Widgets3 tab content"),
plotOutput("widgets3"),
)
)
)
)
server <- function(input, output) {
datasetInput <- reactive({
df <- data_list[[input$Datasets]]
})
output$widgets <- renderPlot({
datasetInput()
par(mfrow=c(1,2))
boxplot(counts(dds, normalized=F), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
boxplot(counts(dds, normalized=T), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Normalized")
})
}
shinyApp(ui, server)
I am sure that I am missing a small trick, could anyone of you shiny masters help me out.
Or may be there is a better way to do the above procedure.
Many thanks in advance
Assuming you have access to both datasets, you plot them both and display the selection. Try this
data_list = list(set_1=mtcars,set_2=iris)
ui <- dashboardPage(
dashboardHeader(title = "Data Visualizer", titleWidth = 300),
dashboardSidebar(
width = 300,
sidebarMenu(
menuItem("Datasets", icon = icon("cog"),
selectInput("Datasets", "Datasets:", choices = list("sample1" = "set_1", "sample2" = "set_2"),
selected = "set_1")),
menuItem("Quality Control", tabName = "widgets", icon = icon("th")),
menuItem("Differential Genes", tabName = "widgets2", icon = icon("th")),
menuItem("Downstream", tabName = "widgets3", icon = icon("th"))
)
),
## Body content
dashboardBody(
tabItems(
# First tab content
# Second tab content
tabItem(tabName="widgets",
h2("widgets"),
#plotOutput("widgets"),
uiOutput("widgets")
),
tabItem(tabName = "widgets2",
h2("Widgets2 tab content"),
),
tabItem(tabName = "widgets3",
h2("Widgets3 tab content"),
plotOutput("widgets3"),
)
)
)
)
server <- function(input, output) {
# datasetInput <- reactive({
# df <- data_list[[input$Datasets]]
# })
#
# output$widgets <- renderPlot({
# datasetInput()
# par(mfrow=c(1,2))
#
# boxplot(counts(dds, normalized=F), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
# boxplot(counts(dds, normalized=T), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Normalized")
#
# })
output$plot1 <- renderPlot({
boxplot(mpg ~ cyl , data=mtcars)
})
output$plot2 <- renderPlot({
boxplot(Sepal.Length ~ Species , data=iris)
})
output$widgets <- renderUI({
if (input$Datasets=="set_1") { plotOutput("plot1")
}else plotOutput("plot2")
})
}
shinyApp(ui, server)

Save reactive value of selectInput when switching tabs

I have a selectInput menu that comes up when I have a certain tab open in my window. I use the same selectInput (inside renderMenu) for multiple tabs. I would like to figure out how to save the value chosen on one tab so it will be the chosen value when switching tabs. Here, for example, if I choose the mtcars plots tab and select 'blue', and then switch to mtcars plots 2, I would like the selected color to be kept at 'blue' rather than switching back to the first option of red.
Yes, I am aware that I am not currently doing anything with the colors, I will add that usage in later.
library(shiny)
library(shinythemes)
library(shinydashboard)
library(tidyverse)
options(warn=-1)
data(iris)
data(mtcars)
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "menume",
sidebarMenuOutput("colormenu"),
menuItem("MTCARS", tabName = "mt", icon = icon("user-tie")),
selectInput("mtvar", "Choose a variable", choices = colnames(mtcars)),
menuItem("IRIS", icon = icon("envelope-open-text"), tabName = "ir"),
selectInput("irvar", "Choose a variable", choices = colnames(iris))
)
),
dashboardBody(
tabItems(
tabItem("mt", uiOutput("mttabs")),
tabItem("ir", uiOutput("irtabs"))
)
)
)
# ui <- secure_app(ui, enable_admin = TRUE)
# Begin Server ----------------------------------------------
server <- function(input, output, session) {
output$colormenu = renderMenu({
req((input$menume=="mt"& input$mtcarstabsall%in%c(2,3))||
(input$menume=="ir"& input$iristabsall%in%c(5,6)))
selectInput("colorme", "Choose a color", c("red", "yellow", "green", "blue", "black"))
})
output$mttabs = renderUI({
output$mtcarsplot1=renderPlot({
ggplot(mtcars, aes_string(x = input$mtvar)) + stat_bin(nbins = 10)
})
output$mtcarsplot2=renderPlot({
ggplot(mtcars, aes_string(x = input$mtvar)) + geom_density()
})
output$mtcarstable1=renderTable({
tabme= head(mtcars, 5)
tabme
})
tabsetPanel(id = "mtcarstabsall",
tabPanel(id = "mttable","MTcars tables",value=1,
fluidRow(box(title = "Table 1", tableOutput("mtcarstable1")))
),
tabPanel(id = "mtplots","mtcars plots",value=2,
fluidRow(box(title = "Plot1", plotOutput("mtcarsplot1"))
)),
tabPanel(id = "mtplots2","mtcars plots 2",value=3,
fluidRow(box(title = "Plot1", plotOutput("mtcarsplot2")))))
})
output$irtabs = renderUI({
output$irisplot1=renderPlot({
ggplot(iris, aes_string(x = input$irvar)) + stat_bin(nbins = 10)
})
output$irisplot2=renderPlot({
ggplot(iris, aes_string(x = input$irvar)) + geom_density()
})
output$iristable1=renderTable({
tabme = head(iris, 5)
tabme
})
tabsetPanel(id = "iristabsall",
tabPanel(id = "mttable","iris tables",value=4,
fluidRow(box(title = "Table 1", tableOutput("iristable1")))
),
tabPanel(id = "irisplots","iris plots",value=5,
fluidRow(box(title = "Plot1", plotOutput("irisplot1"))
)),
tabPanel(id = "irisplots2","iris plots 2",value=6,
fluidRow(box(title = "Plot2", plotOutput("irisplot2"))
)))
})
}
shinyApp(ui, server)
The issue is that the color menu is re-rendering every time you switch tabs and so it resets the selected value. For something like this what you want to do instead is just show/hide the element rather than add/remove it (which is what you're currently doing with req()).
You could use a conditionalPanel in your menu or use the shinyjs package with something like the below (remembering to add shinyjs::useShinyjs() to your ui, to show/hide the color menu:
output$colormenu = renderMenu({
# Remove the req
selectInput("colorme", "Choose a color", c("red", "yellow", "green", "blue", "black"))
})
observe({
# Show/hide menu based on condition using shinyjs::toggle
show_menu_condition <- (input$menume=="mt"& input$mtcarstabsall%in%c(2,3)) || (input$menume=="ir"& input$iristabsall%in%c(5,6))
shinyjs::toggle("colormenu",
condition = show_menu_condition)
})

How to change the theme in semantic.dashboard?

I followed the tutorial on creating a dashboard with Shiny and semantic.dashboard: https://appsilon.com/create-outstanding-dashboards-with-the-new-semantic-dashboard-package/
The example uses a custom theme named "cerulean", but it doesn't appear when running the app. Changing the theme to another one doesn't have any impact either. Does someone know the correct way to change the theme? The example code uses the theme option of dashboardPage as described in the documentation. I didn*t change anything, but the screenshots from the tutorial look different.
Thanks a lot for your help!
library(shiny)
library(semantic.dashboard)
library(ggplot2)
library(plotly)
library(DT)
ui <- dashboardPage(
dashboardHeader(color = "blue",title = "Dashboard Demo", inverted = TRUE),
dashboardSidebar(
size = "thin", color = "teal",
sidebarMenu(
menuItem(tabName = "main", "Main", icon = icon("car")),
menuItem(tabName = "extra", "Extra", icon = icon("table"))
)
),
dashboardBody(
tabItems(
selected = 1,
tabItem(
tabName = "main",
fluidRow(
box(width = 8,
title = "Graph 1",
color = "green", ribbon = TRUE, title_side = "top right",
column(width = 8,
plotOutput("boxplot1")
)
),
box(width = 8,
title = "Graph 2",
color = "red", ribbon = TRUE, title_side = "top right",
column(width = 8,
plotlyOutput("dotplot1")
)
)
)
),
tabItem(
tabName = "extra",
fluidRow(
dataTableOutput("carstable")
)
)
)
), theme = "cerulean"
)
server <- shinyServer(function(input, output, session) {
data("mtcars")
colscale <- c(semantic_palette[["red"]], semantic_palette[["green"]], semantic_palette[["blue"]])
mtcars$am <- factor(mtcars$am,levels=c(0,1),
labels=c("Automatic","Manual"))
output$boxplot1 <- renderPlot({
ggplot(mtcars, aes(x = am, y = mpg)) +
geom_boxplot(fill = semantic_palette[["green"]]) +
xlab("gearbox") + ylab("Miles per gallon")
})
output$dotplot1 <- renderPlotly({
ggplotly(ggplot(mtcars, aes(wt, mpg))
+ geom_point(aes(colour=factor(cyl), size = qsec))
+ scale_colour_manual(values = colscale)
)
})
output$carstable <- renderDataTable(mtcars)
})
shinyApp(ui, server)

How to make conditionalPanel show menu item based on active tab in shinydashboard

I am trying to make a shinydashboard with a bunch of different tabs that show up for different types of data. What I want is when a certain tabItem is selected, for a selectInput item to show up in the sidebar. (Eventually I would like for this to happen for multiple tabs, but I will work on just one tab for now.)
Here's an executable example of what I want:
library(shiny)
library(shinythemes)
library(shinydashboard)
library(tidyverse)
options(warn=-1)
data(iris)
data(mtcars)
tabset1 = tabsetPanel(id = "mtcars",
tabPanel(id = "mtplots","mtcars plots",
fluidRow(box(title = "Plot1", plotOutput("mtcarsplot1"))
)),
tabPanel(id = "mttable","MTcars tables",
fluidRow(box(title = "Table 1", tableOutput("mtcarstable1")))
))
tabset2 = tabsetPanel(id = "iris",
tabPanel(id = "iris","iris plots",
fluidRow(box(title = "Plot1", plotOutput("irisplot1"))
)),
tabPanel(id = "mttable","iris tables",
fluidRow(box(title = "Table 1", tableOutput("iristable1")))
))
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("MTCARS", tabName = "mt", icon = icon("user-tie")),
selectInput("mtvar", "Choose a variable", choices = colnames(mtcars)),
sliderInput("mtlines", "Number of lines", 1,50,10),
# **I would like a conditionalPanel here such that if the tab mtplots is selected, a selectInput as below shows up - but only is visible for that tab **
#selectInput("colorvar", "choose a color", choices = c("red", "yellow", "green", "blue"))
menuItem("IRIS", icon = icon("envelope-open-text"), tabName = "ir"),
selectInput("irvar", "Choose a variable", choices = colnames(iris)),
sliderInput("irislines", "Number of lines", 1,50,10)
)
),
dashboardBody(
tabItems(
tabItem("ir", tabset2),
tabItem("mt", tabset1)
)
)
)
# Begin Server ----------------------------------------------
server <- function(input, output, session) {
output$mtcarsplot1=renderPlot({
ggplot(mtcars, aes_string(x = input$mtvar)) + geom_histogram()
})
output$irisplot1=renderPlot({
ggplot(iris, aes_string(x = input$irvar)) + geom_histogram()
})
output$mtcarstable1=renderTable({
head(mtcars, input$mtlines)
})
output$iristable1=renderTable({
head(iris, input$irislines)
})
}
shinyApp(ui, server)
You can use input$mtcars to determine which tab in the tabsetPanel is active. To render a dynamic/conditional UI element, you can use uiOutput/renderUI. In renderUI, I use req to only render it if the correct tabPanel is chosen:
library(shiny)
library(shinythemes)
library(shinydashboard)
library(tidyverse)
data(iris)
data(mtcars)
tabset1 = tabsetPanel(id = "mtcars",
tabPanel(id = "mtplots","mtcars plots",
fluidRow(box(title = "Plot1", plotOutput("mtcarsplot1"))
)),
tabPanel(id = "mttable","MTcars tables",
fluidRow(box(title = "Table 1", tableOutput("mtcarstable1")))
))
tabset2 = tabsetPanel(id = "iris",
tabPanel(id = "iris","iris plots",
fluidRow(box(title = "Plot1", plotOutput("irisplot1"))
)),
tabPanel(id = "mttable","iris tables",
fluidRow(box(title = "Table 1", tableOutput("iristable1")))
))
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("MTCARS", tabName = "mt", icon = icon("user-tie")),
selectInput("mtvar", "Choose a variable", choices = colnames(mtcars)),
sliderInput("mtlines", "Number of lines", 1,50,10),
# **I would like a conditionalPanel here such that if the tab mtplots is selected, a selectInput as below shows up - but only is visible for that tab **
uiOutput("UI_conditional_input"),
menuItem("IRIS", icon = icon("envelope-open-text"), tabName = "ir"),
selectInput("irvar", "Choose a variable", choices = colnames(iris)),
sliderInput("irislines", "Number of lines", 1,50,10)
)
),
dashboardBody(
tabItems(
tabItem("ir", tabset2),
tabItem("mt", tabset1)
)
)
)
# Begin Server ----------------------------------------------
server <- function(input, output, session) {
output$mtcarsplot1=renderPlot({
ggplot(mtcars, aes_string(x = input$mtvar)) + geom_histogram()
})
output$irisplot1=renderPlot({
ggplot(iris, aes_string(x = input$irvar)) + geom_histogram()
})
output$mtcarstable1=renderTable({
head(mtcars, input$mtlines)
})
output$iristable1=renderTable({
head(iris, input$irislines)
})
output$UI_conditional_input <- renderUI({
req(input$mtcars == "mtcars plots")
selectInput("colorvar", "choose a color", choices = c("red", "yellow", "green", "blue"))
})
}
shinyApp(ui, server)

Resources