I have troubles with Shiny dashboardSidebar - r

I created my shiny dashboard sidebar like this
I linked MenuItem to tabItem, by tabName and in each tabItem I put tabsetPanel
I would like, when I choose group A, to be able to display the different panels that are the subgroups A1, A2, and A3. I would like to do the same for group B and its subgroups. I can't do it, because only the panels in group B are displayed. I would like to keep this dashboardSidebar architecture.
Here are below my scripts
ui <- dashboardPage(
dashboardHeader(title = "DASHBOARD"),
dashboardSidebar(width = 250,
sidebarMenu(
menuItem( "Group A",tabName = "gpA",
selectInput(inputId = "Var1",label="variable 1", choices = c("Total","cat1","cat2"),
selected="Total"),
selectInput(inputId = "Var2",label="variable 2", choices = c("Total","cat1","cat2"),
selected="Total")),
menuItem("Group B",tabName = "gpB")
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "gpA",
fluidRow(box(selectInput(inputId = "Hospital1",choices = c(LETTERS),
label = "Choice hospital 1"),
width = 6,height = 70,
solidHeader = TRUE),
box(selectInput(inputId = "Hopital2",choices = rev(c(LETTERS)),
label = "Choice hospital 2"),
width = 6,height = 70,
solidHeader = TRUE)),
fluidRow( tabsetPanel(
tabPanel("Sub group A2",
box(leafletOutput("")),box(leafletOutput(""))
),
tabPanel("Sub group A3", box(leafletOutput("")),
box(leafletOutput(""))),
tabPanel("Concurrence", leafletOutput(""))
))
),
tabItem(
tabName = "gpB",
fluidRow(box(selectInput(inputId = "Commune",choices = c(letters),
label = "choice a Zip code"),
width = 6,height = 70,
solidHeader = TRUE)),
fluidRow( tabsetPanel(
tabPanel("Sub group B1",
leafletOutput("")
),
tabPanel("Sub group B2",
leafletOutput(""))
))
)
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)

As you are using multiple selectInputs (sub items) within the first sidebarmenu item, you need to use menuSubItem (or menuItem) under that to use the tabName. Here tabName gpA1 is what you need to refer to in dashboardBody. You cannot access the tabpanels with gpA when you have sub-items. Try this
ui <- dashboardPage(
dashboardHeader(title = "DASHBOARD"),
dashboardSidebar(width = 250,
sidebarMenu( id="tabs",
menuItem( "Group A", tabName = "gpA",
selectInput(inputId = "Var1",label="variable 1", choices = c("Total","cat1","cat2"),
selected="Total"),
selectInput(inputId = "Var2",label="variable 2", choices = c("Total","cat1","cat2"),
selected="Total"),
menuSubItem("My Group A", tabName="gpA1", ### <---- refer to this tabName in dashboardBody
icon = icon("line-chart"))
),
menuItem("Group B",tabName = "gpB")
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "gpA1",
fluidRow(box(selectInput(inputId = "Hospital1",choices = c(LETTERS),
label = "Choice hospital 1"),
width = 6,height = 70,
solidHeader = TRUE),
box(selectInput(inputId = "Hopital2",choices = rev(c(LETTERS)),
label = "Choice hospital 2"),
width = 6,height = 70,
solidHeader = TRUE)),
fluidRow( tabsetPanel(
tabPanel("Sub group A2",
box(leafletOutput("")),box(leafletOutput(""))
),
tabPanel("Sub group A3", box(leafletOutput("")),
box(leafletOutput(""))),
tabPanel("Concurrence", leafletOutput(""))
))
),
tabItem(
tabName = "gpB",
fluidRow(box(selectInput(inputId = "Commune",choices = c(letters),
label = "choice a Zip code"),
width = 6,height = 70,
solidHeader = TRUE)),
fluidRow( tabsetPanel(
tabPanel("Sub group B1",
leafletOutput("")
),
tabPanel("Sub group B2",
leafletOutput(""))
))
)
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)

Related

Is it possible to add a sidebarPanel and a mainPanel in each tabPanel using navbarPage?

I have at least 2 individual apps that I want to join in one single app. Although I was using shinyDashboard, I think that it could be a good idea to try with navbarPage.
However, I don't know if it is possible to do what I want with this new approach.
To put you in a context, this is an example of my shinyDashboard. Each tab has a sidebarPanel and mainPanel. I replicated the info in all the tabs, but the idea is that each tab has different things.
However, I was thinking to have this using navbarPage. Do you know if it is possible?
Here I attach you the code that I used for the shinyDashboard:
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Tab1", tabName = "Tab1", icon = icon("th")),
menuItem("Tab2", tabName = "Tab2", icon = icon("th")),
menuItem("Tab3", tabName = "Tab3", icon = icon("th"))
)
),
dashboardBody(
fluidRow(
tabItems(
tabItem(tabName = "Tab1",
sidebarPanel(
numericInput("num",
"Select a number",
min = 1,
value = 10),
checkboxInput("remove", "Remove...", value = FALSE),
sliderInput("slider", "slider", min = 1, max = 30, value=22)
),
mainPanel(
plotOutput("plot1")
)
),
tabItem(tabName = "Tab2",
sidebarPanel(
numericInput("num2",
"Select a number",
min = 1,
value = 10),
checkboxInput("remove2", "Remove...", value = FALSE),
sliderInput("slider2", "slider", min = 1, max = 30, value=22)
),
mainPanel(
plotOutput("plot2")
)
),
tabItem(tabName = "Tab3",
sidebarPanel(
numericInput("num3",
"Select a number",
min = 1,
value = 10),
checkboxInput("remove3", "Remove...", value = FALSE),
sliderInput("slider3", "slider", min = 1, max = 30, value=22)
),
mainPanel(
plotOutput("plot3")
)
)
)
)
)
)
server <- function(input, output, session) {
output$plot1 <- renderPlot({
plot(x=c(1,2,3,4,5,6), y=c(14,3,6,4,56,2))
})
output$plot2 <- renderPlot({
plot(x=c(1,2,3,4,5,6), y=c(14,3,6,4,56,2))
})
output$plot3 <- renderPlot({
plot(x=c(1,2,3,4,5,6), y=c(14,3,6,4,56,2))
})
}
shinyApp(ui, server)
And the code for the navbarPage approach:
library(shinythemes)
library(shiny)
ui <- fluidPage(theme = shinytheme("flatly"),
navbarPage(
collapsible = T,
fluid = T,
"",
tabPanel("Tab 1", "one"),
tabPanel("Tab 2", "two"),
tabPanel("Tab 3", "three"),
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
Thanks very much in advance
You can do that with sidebarLayout. Here I've done it for the first tabPanel:
library(shinythemes)
library(shiny)
ui <- fluidPage(
theme = shinytheme("flatly"),
navbarPage(
title = "Your App Title",
collapsible = TRUE,
fluid = TRUE,
tabPanel(
title = "Tab 1",
sidebarLayout(
sidebarPanel = sidebarPanel(
tags$h3(
"Sidebar Content Here!"
)
),
mainPanel = mainPanel(
tags$h3(
"Main Panel Content Here!"
)
)
)
),
tabPanel(
title = "Tab 2",
"three"
),
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)

Edit contents of Modal popup in R shiny

I would like to edit the contents of a modal popup in R shiny. Below is my code with which I'm able to print the values in the modal popup but I'm not able to edit it.
Server.R
modelnetlist <- function(failed = FALSE){
netlistdata <- readLines('run.scs')
splitText1 <- stringi::stri_split(str = netlistdata, regex = '\\n')
# wrap a paragraph tag around each element in the list
replacedText1 <- lapply(splitText1, p)
modalDialog(
title = "Netlist File",
replacedText1,
easyClose = FALSE,
footer = tagList(
modalButton("Close"),
actionButton("save", "Save")
)
)
}
observeEvent(input$gennet, {
showModal(modelnetlist())
})
ui.R
options(shiny.maxRequestSize=100*1024^2)
ui <- dashboardPage(skin = "yellow",
dashboardHeader(title = "Modelling Automation"),
dashboardSidebar(
sidebarMenu(
# Setting id makes input$tabs give the tabName of currently-selected tab
id = "tabs",
menuItem("Data Processing", tabName = "DP", icon = icon("database"), startExpanded = TRUE,
menuSubItem("Merge", tabName= "Merge"),
menuSubItem("Data", tabName = "Data"),
menuSubItem("Plot", tabName = "Plot", selected = TRUE),
menuSubItem("Parameters", tabName = "Parameters")),
menuItem("Parameter Extraction", icon = icon("book-open"), tabName = "PE"),
menuSubItem("Data Conversion", tabName = "DC"),
menuSubItem("IPL Upload", tabName = "IPL"),
menuSubItem("Netlist Spectre", tabName = "netlist"),
menuSubItem("Spectre logs", tabName = "mylog"),
menuSubItem("Parameter Fitting", tabName = "PF"),
menuItem("Model QA", tabName = "QA", icon = icon("angellist"))
),
textOutput("res")
),
dashboardBody(
tabItems(
tabItem("DP", "Dashboard tab content"),
#tabItem("PE", "Widgets tab content"),
tabItem("Merge", fileInput("mergefiles", "choose the files", accept = c(".txt"), multiple = TRUE), downloadButton("Download", label = "Merged File")),
tabItem("Data",
mainPanel(div(style='overflow-x:scroll',tableOutput("txt"),tableOutput("filetable"),tableOutput("filetable1")))
),
tabItem("Plot",sidebarLayout(sidebarPanel(width=3,
fileInput("datasets", "choose the files", accept = c(".txt",".esd"), multiple = TRUE),
uiOutput("plotdata"),uiOutput("devicetype"), uiOutput("chip"),
uiOutput("macro"),
uiOutput("device"),fluidRow(column(5,uiOutput("minIT2")),column(5,uiOutput("maxIT2"))),
fluidRow(column(5,uiOutput("temperature")), column(5,uiOutput("DCleakage"))),
fluidRow(column(5,uiOutput("varx")),column(5,uiOutput("vary")))
),
mainPanel(width=9,
plotlyOutput("PLOT")))),
tabItem("Parameters",tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"),
div(style="display:inline-block;width:32%;text-align: center;",actionButton("action", label = "Normalize")),
tabsetPanel(type="tabs",
tabPanel("CV Table",div(style='overflow-x:scroll',dataTableOutput('DiodeCVTable')),fluidRow(column(5, actionButton("perimeterCV", label="Change Perimeter")),column(5, actionButton("changeCV", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicCV")),column(5,uiOutput("goldenchipCV"))),plotlyOutput("cvplot")),
tabPanel("DC Table",div(style='overflow-x:scroll',dataTableOutput('DiodeDCTable')),fluidRow(column(5, actionButton("perimeterDC", label="Change Perimeter")),column(5, actionButton("changeDC", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicDC")),column(5,uiOutput("goldenchipDC"))),plotlyOutput("dcplot")),
tabPanel("TLP Table",div(style='overflow-x:scroll',dataTableOutput('TLPTable')), fluidRow(column(5, actionButton("perimeterTLP", label="Change Perimeter")),column(5, actionButton("changeTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicTLP")),column(5,uiOutput("goldenchipTLP"))),plotlyOutput("tlpplot")),
tabPanel("VFTLP Table",div(style='overflow-x:scroll',dataTableOutput('VFTLPTable')), fluidRow(column(5, actionButton("perimeterVFTLP", label="Change Perimeter")),column(5, actionButton("changeVFTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicVFTLP")),column(5,uiOutput("goldenchipVFTLP"))), plotlyOutput("vftlpplot")))),
tabItem("PE","Parameter Extraction Content"),
tabItem("DC",uiOutput("onedevice"),uiOutput('tabs'),
conditionalPanel(condition="input.layer=='CV'", plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
#conditionalPanel(condition="input.layer=='CV 2'", plotlyOutput("plotcv2"),br(), tableOutput("device2cv")),
# conditionalPanel(condition="input.layer=='CV 3'", plotlyOutput("plotcv3"),br(), tableOutput("device2cv")),
conditionalPanel(condition="input.layer=='DC # 25'", plotlyOutput("plotdc125"),br(), tableOutput("device1dc25")),
conditionalPanel(condition="input.layer=='DC # -40'", plotlyOutput("plotdc140"),br(), tableOutput("device1dc40")),
conditionalPanel(condition="input.layer=='DC # 125'", plotlyOutput("plotdc1125"),br(), tableOutput("device1dc125")),
conditionalPanel(condition="input.layer=='DC # 150'", plotlyOutput("plotdc1150"),br(), tableOutput("device1dc150")),
conditionalPanel(condition="input.layer=='TLP'",fluidRow(column(3,uiOutput("stepcountTLP")), column(3, uiOutput("maxvoltageTLP")), column(3, uiOutput("VholdTLP")), downloadButton("DownloadTLP",label = "Download converted data")), plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
#conditionalPanel(condition="input.layer=='TLP 2'", plotlyOutput("plottlp2"),br(), tableOutput("device2tlp")),
conditionalPanel(condition="input.layer=='VFTLP'",fluidRow(column(3,uiOutput("stepcountVFTLP")), column(3, uiOutput("maxvoltageVFTLP")), column(3, uiOutput("VholdVFTLP"))), plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
),
tabItem("PF", uiOutput('modelingtabs'),
conditionalPanel(condition="input.modtab=='CV'",tableOutput("modelingdevice1CV")),
conditionalPanel(condition= "input.modtab=='DC # 25'", tableOutput("modelingdevice1DC25")),
conditionalPanel(condition= "input.modtab=='DC # 40'", tableOutput("modelingdevice1DC40")),
conditionalPanel(condition= "input.modtab=='DC # 125'", tableOutput("modelingdevice1DC125")),
conditionalPanel(condition= "input.modtab=='DC # 150'", tableOutput("modelingdevice1DC150")),# plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
conditionalPanel(condition="input.modtab=='TLP'",tableOutput("modelingdevice1TLP")),# plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
conditionalPanel(condition="input.modtab=='VFTLP'",tableOutput("modelingdevice1VFTLP"))#, plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
),
tabItem("IPL",
fluidRow(box(title = "Model Inputs", width = 8,
fileInput("iplfile", "choose the IPL file", accept = c(".xlsx"), multiple = TRUE),
column(3, uiOutput("modeltype")),
column(3,uiOutput("modeldevtype")),
column(3,uiOutput("modelpath")),
column(3, uiOutput("wrapperfile")),
column(3,uiOutput("zapcon")),
column(3,uiOutput("polarity")),
column(3,uiOutput("sectiontype")),
column(3,uiOutput("designfile")),
column(3, uiOutput("esd_event")),
column(3, uiOutput("esd_exit")),
column(3, uiOutput("modelnodeorder")),
column(3, uiOutput("terminalbias")),
column(3,uiOutput("design")),
column(3,uiOutput("modtemp")),
column(3,uiOutput("ylogaxis")))),
box(title = "Model Parameters in IPL", width = 20, tableOutput("IPLTable"),
uiOutput("newvalue1"),
uiOutput("newvalue2"),
uiOutput("newvalue3"),
uiOutput("newvalue4"))
,fluidRow(box(width = 6, height = 60,actionButton("SpecPlot", label="Spectre Plot", width = 100),
# bsModal("netl", strong("Netlist File", style="color:#0000ff; font-size:120%"),
# "gennet", size = "large", uiOutput("modelnetlist")),
actionButton("HspiPlot", label="Hspice Plot", width = 100),
actionButton("gennet", label="Generate netlist"),
actionButton("ChangeValues", label="Change Values"),
actionButton("save", label = "Save"),
actionButton("Mergesim", label="Merge Simulation Plots"))),
uiOutput("newvalues"),
#conditionalPanel(condition = "input$specplot", withSpinner(plotlyOutput("plotspe"), type = 1, hide.ui = FALSE)),
tags$head(
tags$style(
HTML(".shiny-notification {
height: 100px;
width: 500px;
position:fixed;
top: calc(50% - 50px);;
left: calc(50% - 400px);;
}
"
)
)
),
#box(title = "Simulation", status = "primary", plotlyOutput("plotspe", height = 250)),
fluidRow(column(width=6,
fluidRow(plotlyOutput("plotspe",width = "100%", height = "400px", inline = FALSE))),
column(width=6,
fluidRow(plotlyOutput("plothspi",width = "100%", height = "400px", inline = FALSE)))),
fluidRow(column(width=6,fluidRow(plotlyOutput("plotspechspi",width = "100%", height = "400px", inline = FALSE)))),
# splitLayout(style = "height:400px;", cellWidths = c("800", "800"),
# plotlyOutput("plotspe"), plotlyOutput("plothspi"))
# ,
plotlyOutput("plottlpalongspectre")
),
tabItem("netlist", fluidPage(uiOutput("netlistfile"))),
tabItem("mylog", fluidPage(uiOutput("logfile"))),
tabItem("QA", " QA tab content")# actionButton("ChangeValues", label="Change Values"
)
)
)
**run.scs file:** (File that I'm calling in modelnetlist function to read and display it in the modal)
Simmulator lang=spectre
global 0
paropt options redefinedparams= ignore
parameters vnw=0 vnd=0
parameters area_1=5.5e-12
I would like to edit in the modal popup, but I'm only to print with my code. I tried textInput, textOutput inside modalDialog but it doesn't help. Any suggestions?
In modalDialog function you can use almost any UI elements (see ... parameter)
modelnetlist <- function(failed = FALSE){
netlistdata <- paste(readLines('run.scs'),collapse="\n")
modalDialog(
title = "Netlist File",
textAreaInput("theScript", value=netlistdata),
easyClose = FALSE,
footer = tagList(
modalButton("Close"),
actionButton("save", "Save")
)
)
}
and to get new script in the save button listener use input$theScript
observeEvent(input$save, {
# do whatever you want with input$theScript
if(isTruthy(input$theScript))
writeLines(input$theScript, "run.scs")
})
Note: the path where you save file must be writeable.

R Shinydashboard fileInput issue

I refer to codes from shiny widget gallery to create a fileInput widget on my shinydashboard.
ui.R
fluidPage(
# Copy the line below to make a file upload manager
fileInput("file", label = h3("File input")),
hr(),
fluidRow(column(4, verbatimTextOutput("value")))
)
server.R
function(input, output) {
# You can access the value of the widget with input$file, e.g.
output$value <- renderPrint({
str(input$file)
})
}
I expect my app to show "file upload progress", "upload complete" status and "summary" of the file just like image below.
Below are my codes for shinydashboard:
** for your convenience, refer to "tab Item" = "file".
library(shinydashboard)
library(shiny)
# define user interface
ui <- dashboardPage(
dashboardHeader(title = "B. Times Square"),
dashboardSidebar(
sidebarMenu(
menuItem(text = "Overview", tabName = "overview", icon = icon("balance-scale-right")),
menuItem(text = "Future", tabName = "future", icon = icon("map-signs")),
menuItem(text = "History", tabName = "history", icon = icon("history")),
menuItem(text = "File Upload", tabName = "data", icon = icon("file-upload"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "overview",
fluidRow(
infoBox(title = "Revenue", 1000, icon = icon("hand-holding-usd")),
infoBox(title = "Transaction", 50, icon = icon("bed")),
infoBox(title = "Occupancy %", 40, icon = icon("percentage"))
)
),
tabItem(tabName = "future",
fluidRow(
box(
title = "Revenue [Book]", width = 4,
plotOutput(outputId = "p1-revenue-book")
),
box(
title = "Revenue [Check-In]", width = 4,
plotOutput(outputId = "p2-revenue-checkin")
),
box(
title = "RevPAR", width = 4,
plotOutput(outputId = "p3-revpar")
)
),
fluidRow(
box(
title = "Revenue [Channel]", width = 4,
plotOutput(outputId = "p4-revenue-channel")
),
box(
title = "Occupancy [unit]", width = 4,
plotOutput(outputId = "p5-occupancy")
),
box(
title = "Book vs Cancel [Unit]", width = 4,
plotOutput(outputId = "p6-book-vs-cancel")
)
)
),
tabItem(tabName = "history",
fluidRow(
box(
title = "Revenue [Check-In]", width = 4,
plotOutput(outputId = "p2-revenue-checkin")
),
box(
title = "Revenue [Book]", width = 4,
plotOutput(outputId = "p1-revenue-book")
),
box(
title = "RevPAR", width = 4,
plotOutput(outputId = "p3-revpar")
)
),
fluidRow(
box(
title = "Revenue [Channel]", width = 4,
plotOutput(outputId = "p4-revenue-channel")
),
box(
title = "Occupancy [unit]", width = 4,
plotOutput(outputId = "p5-occupancy")
),
box(
title = "Book vs Cancel [Unit]", width = 4,
plotOutput(outputId = "p6-book-vs-cancel")
)
)
),
tabItem(tabName = ***"data"***,
column(width = 4,
fluidRow(
wellPanel(
fileInput(inputId = "***csv-upload***", label = "File Upload:",
accept = c("csv", ".csv"))
)
)
)
)
)
)
)
# define server
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
I click on "Run App", tried to upload csv file but I don't see any progress bar or file upload complete status after I select a file. The widget basically doesn't work at all.

How to hide sidebarPanel of a Shiny app for a particular tab

My Shiny app has a universal sidebarPanel. I want to hide it for one particular tab, i.e. whenever the used would navigate to that tab the sidebarPanel would collapse. The code I am trying is as follows-
The UI-
library(shiny)
shinyUI(fluidPage (
theme = shinytheme("superhero"),
headerPanel("COVID-19 Data Visualizer"),
sidebarPanel(
width = 2,
selectInput(
"countries",
label = "Select Countries",
choices =
c("B", "C", "A"),
selected = c("A"),
multiple = T
),
submitButton(text = "View")
),
mainPanel (h1(""),
tabsetPanel(
tabPanel(
"Global Status",
div(id="Main"),
plotlyOutput("figG"),
br(),
plotlyOutput("global_time"),
br(),
plotlyOutput("global_cfr"),
br(),
plotlyOutput("global_p"),
br(),
plotlyOutput("global_recov_dead")
),
tabPanel(
"Comparative Charts",
plotlyOutput("fig_confirm"),
br(),
plotlyOutput("fig_dead"),
br(),
plotlyOutput("fig_recov")
),
tabPanel(
"Ratio Analysis",
plotlyOutput("fig_confirm_S"),
br(),
plotlyOutput("fig_confirm_D"),
br(),
plotlyOutput("fig_Ratio"),
br(),
plotlyOutput("fig_cfr_print")
)
))
))
The server part-
server <- function(input, output) {
observeEvent(input$tabs == "Global Status", {
shinyjs::hide(id = "Main")
})
}
I don't really want to use the navbarPage and want single sidebarPanel for all the inputs.
A screenshot of the output I am getting-
Thanks in advance.
Here is an example:
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
sidebarLayout(
sidebarPanel(
id="sidebar",
selectInput(
"countries", label = "Select Countries",
choices = c("B", "C", "A"), selected = "A",
multiple = TRUE
)
),
mainPanel(
tabsetPanel(
tabPanel(
"Global status",
sliderInput("s1", "slider 1", 0, 100, 20)
),
tabPanel(
"Comparative charts",
sliderInput("s2", "slider 2", 0, 100, 50)
),
tabPanel(
"Ratio analysis",
sliderInput("s3", "slider 3", 0, 100, 80)
),
id = "tabset"
),
id="main"
)
)
)
server <- function(input, output){
observeEvent(input[["tabset"]], {
if(input[["tabset"]] == "Comparative charts"){
hideElement(selector = "#sidebar")
removeCssClass("main", "col-sm-8")
addCssClass("main", "col-sm-12")
}else{
showElement(selector = "#sidebar")
removeCssClass("main", "col-sm-12")
addCssClass("main", "col-sm-8")
}
})
}
shinyApp(ui = ui, server = server)

UI side of Shiny not showing up when Running App

So I've learned from my teammates that the server side of a RShiny app doesn't need to be completed for the UI side of an app to be shown.
Here's a bit of my code:
ui <- dashboardPage(
dashboardHeader(title = "Enrolment Analytics"),
dashboardSidebar(sidebarMenu(
#can change tab names and icons here.
menuItem("Summary Tables", tabName = "Summary Tables", icon = icon("table")),
menuItem("Visualizations", tabName = "Visualizations", icon = icon("line-chart"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "Summary Tables",
fluidRow(
box(title = "Teaching Load ", status = "primary", solidHeader = TRUE,
selectInput("courseCode1", "Course code: ",
choices = as.list(unique(data1$discipline))),
numericInput("Month", "1 = January, 2 = February, ..., 12 = December", value = 6),
numericInput("Year", "2007, 2008, ..., 2017", value = 2007)
),
box(title = "Summary ", status = "primary", solidHeader = TRUE,
plotOutput("tl1"))
))
),
tabItem(tabName = "Visualizations",
fluidRow(
box(title = "Teaching Load", status = "primary", solidHeader = TRUE,
selectInput("courseCodeOne", "First discipline: ",
choices = as.list(unique(data1$discipline))),
selectInput("courseCodeTwo", "Second discipline: ",
choices = as.list(unique(data1$discipline))),
selectInput("courseCodeThree", "Third discipline: ",
choices = as.list(unique(data1$discipline)))
),
box(title = "Teaching Load Graph", status = "primary", solidHeader = TRUE,
plotOutput("tl2"))
))
)
)
When I run the app, the sidebar shows Visualizations and Summary Tables but on the server side of things, only the visualizations boxes show up and the summary tables do not.
There were two issues with your code:
1.) tabName must not contain spaces (which is not clear from the help pages).
2.) You had a bracket error (Second tabItem was not included in the brackets of tabItem.
If you correct those two mistakes, the UI is working fine:
ui <- dashboardPage(
dashboardHeader(title = "Enrolment Analytics"),
dashboardSidebar(sidebarMenu(
#can change tab names and icons here.
menuItem("Summary Tables", tabName = "SummaryTables", icon = icon("table")),
menuItem("Visualizations", tabName = "Visualizations", icon = icon("line-chart"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "SummaryTables",
fluidRow(
box(title = "Teaching Load ", status = "primary", solidHeader = TRUE,
selectInput("courseCode1", "Course code: ",
choices = 1:5),
numericInput("Month", "1 = January, 2 = February, ..., 12 = December", value = 6),
numericInput("Year", "2007, 2008, ..., 2017", value = 2007)
),
box(title = "Summary ", status = "primary", solidHeader = TRUE,
plotOutput("tl1"))
)),
## BRACKET ERROR WAS HERE
tabItem(tabName = "Visualizations",
fluidRow(
box(title = "Teaching Load", status = "primary", solidHeader = TRUE,
selectInput("courseCodeOne", "First discipline: ",
choices = 1:10),
selectInput("courseCodeTwo", "Second discipline: ",
choices = 1:10),
selectInput("courseCodeThree", "Third discipline: ",
choices = 1:10)
),
box(title = "Teaching Load Graph", status = "primary", solidHeader = TRUE,
plotOutput("tl2"))
)
)
))
)
server = function(input, output, session){
}
shinyApp(ui, server)

Resources