edit text inputed from TextAreaInput

I have a textAreaInput box,

  textAreaInput("text", label = h3("Text input"), value = ""),
  hr(),
  fluidRow(column(3, verbatimTextOutput("value"))))

I input the following text:
AT4G31950
AT5G24110
AT1G26380
AT1G05675
AT1G69920

I can output the inputted text to the screen.
output$value <- renderText({ input$text })
However, it seems that input$text is a character vector of only 1. Sort of like:
"AT4G31950
AT5G24110
AT1G26380
AT1G05675
AT1G69920"
I want to use this inputted text a line or two late in R code. What I need is a character vector with multiple values:
"AT4G31950" "AT5G24110" "AT1G26380" "AT1G05675" "AT1G69920"

How can I process input$text to change it as needed ?

You can use str_split() from "stringr" package or something similar.

input_text <- "AT4G31950
AT5G24110
AT1G26380
AT1G05675
AT1G69920"
    
library(stringr)
new_text <- as.vector(str_split(input_text, "\n", simplify = TRUE)) 
new_text
#> [1] "AT4G31950" "AT5G24110" "AT1G26380" "AT1G05675" "AT1G69920"

Created on 2019-03-07 by the reprex package (v0.2.1)

Thank you, andresrcs. This worked very well !

I kept the output$value unchanged:
output$value <- renderText({ input$text })

However, in my renderPlot I added some code:
output$plot1 <- renderPlot({**myenter <- as.vector(str_split(input$text, "\n", simplify = TRUE))** ; common <- list(); percnt <- list(); comatgs <- list(); ... })

So, instead of feeding in input$text to my code in the renderPlot, I made a variable, myenter, of the input$text as formatted above, and then used myenter later in the code in renderPlot.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.