Search code examples
rshinyflexdashboard

Reading eventreactive input from inputtextarea in shiny R


I am using a textareaInput for reading data in my dashboard. I tried to covert it into a vector based on the gsub option below.but when I execute this it returns the output as all rows as false. I have data in rdreport data frame with column as Var - in which the values are Mark, Mark1, Mark2 etc.

subset_dataset <-
eventReactive(input$go, {(rdreport$Var %in% (paste0('c("',(gsub('[\r\n]', '","', input$txt)),'")')))})

(paste0('c("',(gsub('[\r\n]', '","', input$txt)),'")')) --> In this portion I am trying to convert the textareaInput to a vector. Input to textarea is given as Mark and Mark1 separated by \n. But the code is not working.

Can somebody help on this?


Solution

  • Dont know where problem in your code

    try it

    library(shiny)
    ui=shinyUI(fluidPage(
    textAreaInput("txt",label = ""),
    actionButton("go","go"),
    textOutput("rez")
      )
    
      )
    
    server=function(input,output){
    
      DF=c("A","B","CC","DT","HJKH") # TEST DATA
      subset_dataset <-eventReactive(input$go, {
        DF %in% unlist(strsplit(x =input$txt,split = '[\r\n]' ))
        })
    
      output$rez=renderText(subset_dataset())
    }
    
    shinyApp(ui,server)