r - Auto complete and selection of multiple values in text box shiny -
is possible select multi values using auto complete strings similar google search , stack overflow tags selection in shiny text box.
dataset<-cbind("john doe","ash","ajay sharma","ken chong","will smith","neo"....etc)
i want select multiple variables above dataset auto fill in textbox , pass server.r
ui.r
shinyui(fluidpage( titlepanel("test"), sidebarlayout( sidebarpanel( helptext("text"), textinput("txt","enter text",""), #pass dataset here auto complete ), mainpanel( tabsetpanel(type="tab",tabpanel("summary"),textoutput("text2")) ) ) ))
server.r
# server.r shinyserver(function(input, output) { output$text2<- rendertext({ paste("hello",input$txt) }) } )
edited
i have used select2input shinysky selecting mulitiple varialbes have added submit button selected values together.
#ui.r select2input("txt","this multiple select2input",choices=c("a","b","c"),selected=c("")), actionbutton("go","submit")
i want bind selected option lets user selected , c new variable is
#server.r input$go #if pressed submit button var<-cbind("a","c") output$text<-rendertext({ print ("var")})
but not working
look shinysky
package , textinput.typeahead
. can further customize style of textinput
yourself. edit: added example select2input
shinysky
package reference
rm(list = ls()) library(shinysky) library(shiny) my_autocomplete_list <- c("john doe","ash","ajay sharma","ken chong","will smith","neo") ui <- shinyui( fluidpage(tags$style(type="text/css",".shiny-output-error { visibility: hidden; }",".shiny-output-error:before { visibility: hidden; }"), tags$style(type="text/css","#search { top: 50% !important;left: 50% !important;margin-top: -100px !important;margin-left: -250px !important; color: blue;font-size: 20px;font-style: italic;}"), mainpanel( # 1 way of doing textinput.typeahead(id="search", placeholder="type name please", local=data.frame(name=c(my_autocomplete_list)), valuekey = "name", tokens=c(1:length(my_autocomplete_list)), template = html("<p class='repo-language'>{{info}}</p> <p class='repo-name'>{{name}}</p>") ), br(),br(), # using select2input select2input("select2input1","",choices=c(my_autocomplete_list),type = c("input", "select")) ) ) ) server <- function(input, output, session) {} shinyapp(ui = ui, server = server)
edit 2 per request. please wrap objects in reactive
expressions did e.g. var <- reactive({...})
can re-use later
rm(list = ls()) library(shinysky) library(shiny) my_autocomplete_list <- c("john doe","ash","ajay sharma","ken chong","will smith","neo") ui <- shinyui( fluidpage(sidebarpanel(select2input("txt","",choices=c("a","b","c"),selected=c("")), br(),actionbutton("go","submit"), width =2), mainpanel(textoutput('text')) ) ) server <- function(input, output, session) { var <- reactive({ if(input$go==0){return()} isolate({ input$go cbind("a","c") }) }) output$text <- rendertext({var()}) } shinyapp(ui = ui, server = server)
Comments
Post a Comment