在我的 Ui.R
流体页(
titlePanel("Data Browser"),
sidebarLayout(
sidebarPanel(
width = 12,
# radioButtons("filetype", "Select file type",choices=c("csv file","xlsx file", "xls file")),
fileInput("file","Choose file to upload..",accept = c("text/csv","text/comma-separated-values,text/plain",".csv",".xlsx",".xls"))
),
mainPanel(
width = 12,
uiOutput("data_browsing")
)
)
) #end of fluid row #2
服务器.R
data <- eventReactive(input$file, {
extension <- tools::file_ext(input$file$name)
filepath <- input$file$datapath
switch(extension,
csv = read.csv(filepath),
xls = readxl::read_xls(filepath),
xlsx = readxl::read_xlsx(filepath)
)
})
output$about_file<-renderTable({
summary(input$file) #input$file1
})
output$display <- renderDataTable({
dataset = data()},
10,
options = list(scrollX = TRUE))
output$data_browsing<-renderUI({
if(is.null(data())){
}else if(length(data())==1){
h4(br(),br(),"Mismatch in formats of file selected and uploaded!",style = "color:red")
}else{
tabsetPanel(tabPanel("Data Browse",dataTableOutput("display"))
) }})
所以我想添加一个选项,让用户在本地机器和数据库上像 file_input 一样浏览,并让数据集通过我的其他代码进行可视化。