1
我正在創建一個閃亮的儀表板,它在側欄中有兩個選項卡。 Tab1用於導入csv和Tab2用於顯示所選變量的圖表。SideBar在儀表板主體上沒有渲染任何東西:R Shiny Dashboard
TAB2有1個選擇輸入選項選擇變量情節
問題:點擊側邊欄的選項卡後,我的儀表盤體不會改變。它總是向我顯示Tab1內容即csv導入結果。 因此,儘管點擊TAB2在側邊欄的,什麼也沒有發生
以下是我的腳本
library(shinydashboard)
library(shiny)
library(DT)
#UI
sidebar=dashboardSidebar(width=200,
sidebarMenu(id="sidebar",
menuItem("Data UpLoad", tabName = "dashboard", icon = icon("table"),
fileInput('file1','Choose CSV File',
accept=c('text/csv','text/comma-separated-values,text/plain', '.csv'))),
menuItem("Uni Variate", tabName = "Uni", icon = icon("line-chart"),
fluidRow(
selectInput("options",label=h5("Select Column"),"")))))
body= dashboardBody(
tabItems(
tabItem(tabName="dashboard",class='active',
fluidRow(
box(
title="Data",solidHeader = TRUE, collapsible = TRUE,
div(style='overflow-x: scroll',tableOutput("table1"))))),
tabItem(tabName = "Uni",
fluidRow(box(title="Plot",solidHeader = TRUE,plotOutput("plot1"))),
h2("tab content"))))
dashboardPage(
dashboardHeader(title= "test"),sidebar,body)
#Server
server <- function(input, output,session) {
data_set <- reactive({
req(input$file1)
inFile <- input$file1
data_set1<-read.csv(inFile$datapath)
list(data=data_set1)
})
# updating select input of second tab in shiny side bar
observe({
updateSelectInput(
session,
"options",
choices = names(data_set()$data))})
# tab1
output$table1= renderTable({
de=as.data.frame(data_set()$data[1:7,])})
#tab2
output$plot1 <- renderPlot({ggplot(data_set$data,aes(y=input$options,x=Prediction))+geom_histogram(binwidth=0.50, fill="blue") })
}
每個幫助是很重要的!
是否有可能爲主菜單下的每個menusubItem提供輸入選項?如果是這樣,你能指導我一個例子嗎?當我嘗試這樣做時,表格/繪圖不會渲染。謝謝 – user5249203