Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

using pickerInput in r shiny to apply function

$
0
0

I would like to be able to apply a function to a given set of columns from the RLdata10000 dataset. I have been going through shiny tutorials and am attempting to learn how to use observeEvent and actionButton. However, I would like to be able to pick the columns I use so I came across pickerInput. In short, I would like to be able to pick a set of columns from RLdata10000, and apply the function via actionButton.

My problem is that I get an error: Error: unused argument (RLdata10000). My code is below. I would like to be able to do this with two data files eventually. Any help would be appreciated.

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)

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>