1
我有一段代碼,我需要顯示不同的表,具體取決於R中SelectInput命令的userinput。 我只想在userinput爲Level 2時顯示錶base_level2並顯示base_level3當用戶選擇selectInput級別3 我不確定被動命令是否幫助我,但在那個時候我真的很困惑我該怎麼做。 預先感謝大家。如何根據用戶輸入更改顯示錶輸入
ui.R
library(shiny) library(radarchart) library(fmsb)
# Define UI for random distribution application
shinyUI(pageWithSidebar( headerPanel('A competency profiling model
for Software engineers'), sidebarPanel(
selectInput("dataset", "Choose Level of competence :",
choices = c("Level 2", "Level 3"), selected = "Level 2"),
radioButtons("selectedCategory","Make your choice of Skills : ", rownames(x), selected = "Professional skills"),
checkboxGroupInput('selectedLevels', 'Who to include',
names(scores[]), selected="Technical Junior"),
sliderInput("Candidate", "Candidate number:",
min = 1, max = 50, value = 1)),
mainPanel(
tabsetPanel(type="tabs",
tabPanel('Level2/Level3 RCD frame', tableOutput("table")),
tabPanel("Candidates ACD frame ", tableOutput("candidate")),
tabPanel("Radar Plot #1", chartJSRadarOutput("radar", width = "450", height = "300"), width = 7),
tabPanel("Radar Plot #2" ,plotOutput("triangle", width = "100%", height = "900px"), width = 7),
tabPanel("Clustering Plots",plotOutput("cluster", width = "100%", height = "900px"), width = 7),
tabPanel("Correlation Plots",plotOutput("corellation",width =
"100%", height =
"900px"),width = 7),
tabPanel("Classification Tree", plotOutput("class",width = "100%", height = "900px"),width = 7))
)
)
)
server.R
function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"Level 2" = as.matrix(base_level2),
"Level 3" = as.matrix(base_level3)
)
})
output$table <- renderTable({(datasetInput)},rownames=TRUE,striped = TRUE,hover = TRUE, bordered = TRUE)
由於'datasetInput'是一個反應,你必須以這種方式使用'datasetInput()' – HubertL
對我而言的任何反饋? –