I am trying to upload a file using fileInput()
function and use the R package IDEAFilter to filter it and show the filtered data. But it seems that I can not filter a reactive expression using IDEAFilter package. I am not sure if that’s true or my code is wrong.
Here is my code:
library(shiny)
library(bslib)
library(IDEAFilter)
library(dplyr)
ui <- page_fixed(
fileInput("file1", "Choose CSV File", accept = ".csv"),
IDEAFilter_ui("data_filter"),
verbatimTextOutput("file1_contents"),
tableOutput("contents"),
tableOutput("contents1")
)
server <- function(input, output) {
output$file1_contents <- renderPrint({print(input$file1)})
output$contents <- renderTable({
file <- input$file1
req(file)
ext <- tools::file_ext(file$datapath)
validate(need(ext == "csv", "Please upload a csv file"))
a<- read.csv(file$datapath)
a
})
filtered_data<-reactive({
file <- input$file1
req(file)
ext <- tools::file_ext(file$datapath)
validate(need(ext == "csv", "Please upload a csv file"))
a<- read.csv(file$datapath)
IDEAFilter("data_filter", data =a,verbose = FALSE)
})
output$contents1 <- renderTable({
filtered_data()
})
}
shinyApp(ui, server)
I tried to upload data and filter it using IDEAFilter package.
It seems that IDEAFilter package is not working with reactive data. If I use the package with data uploaded from the computer it works, but not with reactive data.
user28602420 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.