我正在尝试在Shiny Dashboard侧边栏中包含一个文件输入,并在仪表板主体中包含一个框,尽管我多次尝试,但只要我的文件输入位于补充工具栏中,我就无法在仪表板主体中看到任何框。每一个帮助都很重要。再次感谢。
以下是1个示例代码
#UI
library(shinydashboard)
dashboardPage(
dashboardHeader(title= "my dashboard"),
dashboardSidebar(width=250,
sidebarMenu(
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("Widgets", tabName = "widgets", icon = icon("th"))
)),
dashboardBody(
tabItems(
#first tab content
tabItem(tabName="dashboard",
fluidRow(
box(title="Data",solidHeader = TRUE, collapsible =
TRUE,tableOutput("table1"))
)
),
tabItem(tabName="widgets")))
)
#server
library(shiny)
library(shinydashboard)
library(dplyr)
server <- function(input, output) {
output$table1= renderTable({
inFile=input$file1
if(is.null(inFile))
return(NULL)
read.csv(inFile$datapath)
})
}