0

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?

Batanichek
  • 7,761
  • 31
  • 49
Aizen
  • 561
  • 1
  • 9
  • 19
  • 1
    try to use `(strsplit(x =input$txt,split = '[\r\n]' ))` - to split string into vector.. paste not evaluate you code of 'c(...)' it create simply strung of text – Batanichek Nov 29 '16 at 09:22
  • Thanks, now I can see a vector input, but when I enter multiple values in the textAreaInput it returns all rows as false, If i enter only one then correct result is displayed. what could be the issue? – Aizen Nov 29 '16 at 09:46

1 Answers1

1

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)
Batanichek
  • 7,761
  • 31
  • 49