我希望能够将函数应用于RLdata10000
数据集中给定的一组列。我一直在学习闪亮的教程,并试图学习如何使用observeEvent
和actionButton
. 但是,我希望能够选择我使用的列,所以我遇到了pickerInput
. 简而言之,我希望能够从中选择一组列RLdata10000
,并通过actionButton
.
我的问题是我收到一个错误: Error: unused argument (RLdata10000)
. 我的代码如下。我希望最终能够使用两个数据文件来做到这一点。任何帮助,将不胜感激。
library(shiny)
library(DT)
library(shinyWidgets)
library(plyr)
library(dplyr)
library(RecordLinkage)
data(RLdata10000)
cleanup <- function(x){
x <- as.character(x) # convert to character
x <- tolower(x) # make all lowercase
x <- trimws(x, "both") # trim white space
return(x)
}
ui <- basicPage(
h2("Record Linkage Data"),
actionButton(inputId = "clean", label = "Clean Data")
pickerInput(width = "75%",
inputId = "pick_col1",
label = "Select columns to display",
choices = colnames(RLdata10000),
selected = colnames(RLdata10000),
options = list(
`actions-box` = T,
`selected-text-format` = paste("count > ", length(colnames(RLdata10000)) - 1),
`count-selected-text` = "Alle",
liveSearch = T,
liveSearchPlaceholder = T
),
multiple = T)
DT::dataTableOutput("mytable")
)
server <- function(input, output) {
observeEvent(input$clean, {
output$mytable = DT::renderDataTable({
lapply(input$pick_col1, cleanup)
})
}
}
shinyApp(ui, server)