Я создал флажок скрывать вкладки, чтобы скрыть вкладки, для которых я упомянул условие на сервере. Я хочу заменить флажок или скрыть флажок после упоминания значения по умолчанию как ИСТИНА или ЛОЖЬ. Чтобы после запуска приложения пользователь не мог видеть скрытые вкладки. Пожалуйста, ознакомьтесь с кодом ниже.
library(shiny)
library(shinydashboard)
library(datasets)
ui <- shinyUI(fluidPage(
titlePanel("Test of Skills"),
sidebarLayout(
sidebarPanel(("Details Enter Page"),
checkboxInput(inputId = "hide_tab",label = "Hide 'Data Selected' tab"),
# selectInput(inputId = "hide_tab",label = "Hide 'Data Selected' tab",choices = c(TRUE,FALSE), multiple = FALSE),
selectInput("data", "Select the dataset which has to be selected for analysis",
choices = c("iris" , "pressure" , "USArrests")),
radioButtons("color", "Select the color of the histogram",
choices = c("green", "orange","red","pink")),
sliderInput("bins", "select the number of bins required for histogram",
min = 5 , max = 25 , value = 5 , step = 1),
numericInput("obs" , "Select the number of observation required for dataset" ,
min = 5, max = 100 , value = 5 , step = 1),
submitButton("Confirm")),
mainPanel((" Analysis Of the Dataset"),
tabsetPanel(id = "my_tabs",type = c("pills"),
tabPanel("Summary", h1(textOutput("MysumHeader")) ,
verbatimTextOutput("Mysum")),
tabPanel("Structure and Observation" , h1(textOutput("Mystrobsheader")),
verbatimTextOutput("Mystr") , h1(textOutput("Myobsheader")), verbatimTextOutput("Myobs")),
tabPanel("Data Selected",tableOutput("Mydata")),
tabPanel("Histogram Plot"))
))))
server <- shinyServer(function(input,output,session){
observeEvent(input$hide_tab,ignoreNULL = FALSE, ignoreInit = TRUE, {
if(isTRUE(input$hide_tab)) {
shiny::hideTab(inputId = "my_tabs",
target = "Summary")
shiny::hideTab(inputId = "my_tabs",
target = "Histogram Plot")
} else {
shiny::showTab(inputId = "my_tabs",
target = "Summary")
shiny::showTab(inputId = "my_tabs",
target = "Histogram Plot")
}
})
output$Mysum <- renderPrint({
summary(get(input$data))
})
output$MysumHeader <- renderText({
paste("The Dataset which is selected for analysis" , input$data)
})
output$Mystr <- renderPrint({
str(get(input$data))
})
output$Mystrobsheader <- renderText({
paste("DataSet selected for structure is " , input$data)
})
output$Myobs <- renderPrint({
head(get((input$data)))
})
output$Myobsheader <- renderText({
paste("First" , input$obs , "Selected from the datase" , input$data)
})
output$Mydata <- renderTable({
View(get(input$data))
})
})
shinyApp(ui,server)