r - 我们如何根据我的简单代码在 rshiny 中添加上传/搜索数据库和本地机器中的数据集的选项?
问题描述
在我的 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 一样浏览,并让数据集通过我的其他代码进行可视化。
解决方案
推荐阅读
- android - Android 上 Facebook 登录 Firebase 的问题 - E/GraphResponse
- typo3 - 列表查看新记录类别标签名称 TYPO3
- java - 是否可以避免使用通过 META-INF 中的服务定义获取的 JAX-WS 提供程序?
- sorting - `--key (-k)` 如何对命令 `sort` 起作用?
- c# - 在 Visual Studio 2010 中检索存储在 SQL Server CE 数据库中的信息
- python - 在python中对类内的变量进行操作
- php - 在 Symfony 4 中将身份验证与您的用户实体分离?
- javascript - javascript在点击时使div变大或变小
- ubuntu - 如何让 Ubuntu 18.04 自动登录 i3
- javascript - 为什么从函数引用调用静态类方法时未定义但直接调用时未定义?