我正在尝试在R
shiny
. 我想做的第一件事是选择两个 csv 文件显示在页面上。据此: https : //community.rstudio.com/t/creating-tables-in-r-shiny-dynamically/14586我需要dataTableOutput
为. 但是,当我尝试时,该应用程序不起作用。UI
renderDataTable
server
下面的代码只允许用户加载一个 csv 文件。
X <- c("plyr", "dplyr", "tm", "wordcloud", "SnowballC", "stringdist", "tidytext",
"rmarkdown", "knitr", "quanteda", "qdap", "reshape", "stringr", "RecordLinkage",
"data.table", "rvest", "shiny", "shinydashboard", "DT")
lapply(X, FUN = function(X){
do.call("library", list(X))
})
用户界面
ui <- dashboardPage(
dashboardHeader(title = "Record Linkage App"),
dashboardSidebar(
sidebarMenu(
## Tab 1 -- Specify Task
menuItem("Select Task And Upload Files", tabName = "task", icon = icon("file-text-o")),
## Tab 2 -- View Raw Data Files
menuItem("View Raw Data", tabName = "raw", icon = icon("file-text-o")),
## Tab 3 -- View Processed Data Files
menuItem("View Processed Data", tabName = "processed", icon = icon("file-text-o")),
## Tab 4 -- Select Training Set
menuItem("Select Training Set", tabName = "mltrain", icon = icon("file-text-o")),
## Tab 5 -- View Weight & Probabilities (choose which chart to view or both?)
menuItem("Visualize Distributions", tabName = "distributions", icon = icon("bar-chart-o")),
## Tab 6 -- View Results (review, match and trash files--need to be able to choose dataset)
## Want to be able to add checkboxes to select rows for inclusion in deletion later on
menuItem("View Result Files", tabName = "fileview", icon = icon("file-text-o"))
)), # close dashboard sidebar
#### Dashboard Body starts here
dashboardBody(
tabItems(
### Specify Task & Upload Files Tab
tabItem(tabName = "task",
radioButtons("task", "Select a Task:", c("Frame Deduplication", "Frame Record Linkage")),
fileInput("selection", "Upload Files:", multiple = T,
accept = c(".xls", "text/csv", "text/comma-separated-values, text/plain", ".csv")),
helpText(paste("Please upload a file. Supported file types are: .txt, .csv and .xls.")),
helpText(paste("Note: Record Linkage requires two data frames."))
), # close first tabItem
tabItem(tabName = "raw",
helpText(paste("This tab displays the raw, unprocessed data frames selected in the previous tab.")),
helpText(paste("Select the columns you wish to display. These columns will be used for string comparisons")),
dataTableOutput("contents"),
dataTableOutput("contents")
)
) # close tabItems
) # close dashboardBody
) #close dashboardpage
options(shiny.maxRequestSize = 100*1024^2)
服务器
server <- function(input, output, session) {
output$contents <- renderDataTable({
req(input$selection)
#browser()
read.csv(input$selection$datapath)
})
output$contents <- renderDataTable({
req(input$selection)
#browser()
read.csv(input$selection$datapath)
})
}
shinyApp(ui, server)
我想:
- 能够上传多个文件
- 从每个文件中选择要显示的列 (
checkboxInput
?)
任何帮助将不胜感激。