Hi all,
I have a value in Excel like below. So when i copy this cells and paste in Shiny, "He Ca" is getting treated as 2 words . Please refer below
library(shiny)
ui <- fluidPage(
selectizeInput(
"foo",
label = "inputs",
choices = "",
multiple = T,
options = list(delimiter = " ", create = F)
),
textOutput("results")
)
server <- function(input, output, session) {
output$results <- renderText(
paste(paste("item", input$foo), collapse = " || ")
)
}
shinyApp(ui, server)
Actual output
Expcted output
Can this be achieved?
I don't think the first screenshot, is of the example app you shared... the example app had no choices... adding the choices seems to give what you want though. maybe
library(shiny)
ui <- fluidPage(
selectizeInput(
"foo",
label = "inputs",
choices = c("En","He Ca"),
multiple = T,
options = list(delimiter = " ", create = F)
),
textOutput("results")
)
server <- function(input, output, session) {
output$results <- renderText(
paste(paste("item", input$foo), collapse = " || ")
)
}
shinyApp(ui, server)
No No... Basically there is nothing in choices.
I want to give user to directly copy and paste from Excel....
I know we can achieve this by giving choices
Make sense ?
no... or at least, I've not come across such a widget before.
Have you ?
You could make a text box that choice options can be pasted into; and make a selectize fom that... but it may defeat the point.
library(shiny)
ui <- fluidPage(
textAreaInput("optionsmaker",label="put the options to select from here:"),
selectizeInput(
"foo",
label = "inputs",
choices="",
multiple = T
),
textOutput("results")
)
server <- function(input, output, session) {
live_choices <- eventReactive(input$optionsmaker,{
om <- input$optionsmaker
unlist(strsplit(om,split = "\n"))
}) |> debounce(millis = 500)
observeEvent(live_choices(),
{
updateSelectizeInput(session=session,
inputId = "foo",
choices=live_choices())
})
output$results <- renderText(
paste(paste("item", input$foo), collapse = " || ")
)
}
shinyApp(ui, server)
system
Closed
November 4, 2022, 1:24pm
5
This topic was automatically closed 42 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.