Re: server-side interaction for autocomplete/suggestion to inputs

444 views
Skip to first unread message

Yihui Xie

unread,
May 18, 2014, 1:45:13 AM5/18/14
to Marco Blanchette, shiny-discuss
You can test the development version of shiny
(https://github.com/rstudio/shiny), which includes an implementation
of the server-side processing for selectizeInput(), and selectize
support auto-completion.

# in ui.R
selectizeInput('foo', choices = NULL, ...)

# in server.R
shinyServer(function(input, output, session) {
updateSelectizeInput(session, 'foo', choices = data, server = TRUE)
})

where 'data' is the character vector of choices (e.g. tens of
thousands of gene names in your case).

Regards,
Yihui


On Sat, May 17, 2014 at 11:49 AM, Marco Blanchette <m...@stowers.org> wrote:
> Hi guys, just started to work with Shiny, love the product! this will change
> the way we do analyst at our Institute!
>
> I am not sure if this topic been brushed on before, but I would like to
> provide suggestions/autocompletion to user inputs. The challenge is that the
> lists will be very very longs (several tens of thousand choices, i.e. gene
> names from different species). I'd like to provide server-side generated
> suggestions to increase the response time but I am not sure what is the best
> solution.
>
> I wrote a custom widget that uses jquery_ui autocomplete and read a list of
> suggestion provide by the server. It works for short list (up to a few
> hundreds), but more than that, it becomes unusable. The strategy would be to
> hit a CGIs as the source that would parse the long list as a shorter one and
> send back a json formatted answer. However, I'm having some problem to
> understand the http server model used by shiny.
>
> Is is possible to trigger CGI response from the shiny www directory? (that
> would probably be optimal)
> Does someone has already solved that problem and has a suggestions?
>
> My personal widget with jquery capabilities:
>
> autocompleteInput <- function(inputId, label, value = "") {
>
> tagList(
>
> ## This makes web page load the JS file in the HTML head.
>
> ## The call to singleton ensures it's only included once
>
> ## in a page.
>
> shiny::singleton(
>
> shiny::tags$head(
>
> shiny::tags$script(src="jquery-ui-1.10.4.min.js"),
>
> shiny::tags$link(rel="stylesheet",
> href="jquery-ui-1.10.4.min.css"),
>
>
> shiny::tags$script(paste0('$(function() {$( "#',inputId,'" )
>
> .autocomplete({source:
> "./test.json",
>
> minLength: 3
>
> });
>
> });'))
>
> )
>
> ),
>
> shiny::tags$div(class="ui-widget",
>
> shiny::tags$label(label, `for` = inputId),
>
> shiny::tags$input(id = inputId, value = value)
>
> )
>
> )
>
> }

Blanchette, Marco

unread,
May 19, 2014, 5:01:28 PM5/19/14
to Yihui Xie, shiny-discuss
Hey I like that!! And quite fast on top of that!!!

Little issue thoughŠ On our institute server, I install the dev version
under my personal library, work fine from the localhost host (using
runApp() ) and also works from shiny server
(http://ourServer:3838/mab/coverage-app)

However, it breaks when I try to run in on a shiny server running on aws
where I deploy the development package as root. I confirm that if I am
running R as the shiny user I am using version 0.9.1.9008:
> packageVersion('shiny')
[1] Œ0.9.1.9008¹


Also, I did confirm that the app is working if comment out the line

updateSelectizeInput(session, 'foo', choices = data, server = TRUE)


Any idea what could cause the different behavior and how to fix it?

Thanks


-- Marco Blanchette, Ph.D.
Genomic Scientist
Stowers Institute for Medical Research
1000 East 50th Street
Kansas City MO 64110
www.stowers.org


Tel: 816-926-4071
Cell: 816-726-8419
Fax: 816-926-2018

Yihui Xie

unread,
May 19, 2014, 5:06:42 PM5/19/14
to Blanchette, Marco, shiny-discuss
Glad that it helped at least locally. By "it breaks", what exactly did
you see? Is there an error message in the app (on the web page), or
the app simply does not load?

Regards,
Yihui

Marco Blanchette

unread,
May 20, 2014, 1:23:58 AM5/20/14
to shiny-...@googlegroups.com
Thanks, to bring this to a close, restarting shiny server solved the problem (of course, right!)

Thanks a bunch Yiuhui!

Nellster Hellster

unread,
Jul 17, 2014, 3:37:55 AM7/17/14
to shiny-...@googlegroups.com
Hi Marco!

I have stumbled upon your post yesterday: I am trying to understand if it is possible to run Shiny on an external server.
I understand that you managed that on your institute server, so I was sondering if you could give me some tips about it.
I also just start on web developpement, so I apologize if my questions are too silly.
- did you have to go through Shiny server to run Shiny onto your institute server?
- Was it easy? Did you use a specific document to do the installation? If so, would you be able to give me some indications, so that
I get my hand on this document. I have looked around and found mostly info about using Shiny server but little about using shiny on an
external server.

Thanks for your help!
hello from France :)

Nelly




Marco Blanchette

unread,
Jul 27, 2014, 11:56:48 AM7/27/14
to Nellster Hellster, shiny-...@googlegroups.com
Hi Nellster, sorry for the delayed answer. I just realized that my gmail account was the one receiving mails from google groups...

I am not sure I fully understand your question(s) as there is many points of inquiries...

I'll try to answer what I think you are missing... 

Shiny server is a separate piece from the R shiny package. The shiny server basically listen to the internet and will fire up an R session running the server.R and ui.R scripts when someone points there web browser to an app URI. So, if one wants to run his own app, no need for shiny server. If one wants to write an app that will be used by others for data mining/exploration, for example, yes, you need the server (having everyone firing up a local copy of an app does not really make sense)

Since we have 5 computational servers sharing the same file system through NFS, we have shiny server install on all of our boxes. In addition, I am managing a couple of servers running on AWS instances, so yes, there is multiple ways to host a shiny server, be it internal or fully external. 

As of facility, that depends on what you mean. Installing the software takes about 5 mins, just follow the instruction on the shiny server download page. Configuration is also very trivial, you need to reed the administration manual. Not sure what type of config you have in mind, but I use two models, depending on the box. On the institute server, we have per user app service configured. Everyone can put their app on their ~/ShinyApps directory and pointing a web browser to http://shiny.institute.org/myId/myApp will fire up a given user app. On the aws boxes, I am using a single directory and the shiny user is the own who own the processes. 

That said, the management of a computational/web server is a different storry. Difficulty will depends on your ease with admistarting a unix box and your understanding of network communication in general. Not sure exactly how one could start, but testing stuff on an AWS instance first (or a VM if you guys run unix machines as VMs) makes it for a less painful learning curve. 

I'll post some notes and links to the documents once I'm in front of a computer (I'm on an iPad right now)

Let me know if you have other questions

Marco
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/d5wUq1dmyAk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages