Reputation: 1092
I am playing around with the shiny packages for some hours now, and wanted to make a select input widget that enables me to download a certain data set from the server. So i figured out a way to get me this data frame containing all my IDs for downloading:
> dput(runDf)
structure(list(runName = c("5587bfe560b27bb14676ce46", "5587bfde60b27bb14676ce2c",
"5587bfd860b27bb14676ce0e", "5587bfd260b27bb14676ccaa", "5587bfc160b27bb14676cbb9",
"5587bfaf60b27bb14676cba5"), pipeline = c("gentrap", "gentrap",
"gentrap", "gentrap", "gentrap", "gentrap"), nSamples = c(16L,
10L, 12L, 60L, 125L, 8L)), .Names = c("runName", "pipeline",
"nSamples"), row.names = c(NA, 6L), class = "data.frame")
runName pipeline nSamples
1 5587bfe560b27bb14676ce46 gentrap 16
2 5587bfde60b27bb14676ce2c gentrap 10
3 5587bfd860b27bb14676ce0e gentrap 12
4 5587bfd260b27bb14676ccaa gentrap 60
5 5587bfc160b27bb14676cbb9 gentrap 125
6 5587bfaf60b27bb14676cba5 gentrap 8
Out of this dataframe i parse a selectInput box containing the Runids from the df, like this:
tst <- as.vector(runDf$runName)
names(tst) <- runDf$runName
selectInput("selectRunid", label = "Select RunID", choices = tst)
#OUTPUT of selectInput
<div class="form-group shiny-input-container">
<label class="control-label" for="selectRunid">Select RunID</label>
<div>
<select id="selectRunid"><option value="5587bfe560b27bb14676ce46" selected>5587bfe560b27bb14676ce46</option>
<option value="5587bfde60b27bb14676ce2c">5587bfde60b27bb14676ce2c</option>
<option value="5587bfd860b27bb14676ce0e">5587bfd860b27bb14676ce0e</option>
<option value="5587bfd260b27bb14676ccaa">5587bfd260b27bb14676ccaa</option>
<option value="5587bfc160b27bb14676cbb9">5587bfc160b27bb14676cbb9</option>
<option value="5587bfaf60b27bb14676cba5">5587bfaf60b27bb14676cba5</option></select>
<script type="application/json" data-for="selectRunid" data-nonempty="">{}</script>
</div>
</div>
Now i want to be able to extract the values from the selectInput()
output. So that i can retrieve the correct data file from the server.
input$selectRunid == <value> {
Jin <- content(GET("http://stats/gentrap/alignments?runIds=<MYRUNID>&userId=dev",
add_headers("X-SENTINEL-KEY" = "dev"), as = "parsed"))}
Any hints are appreciated!
Upvotes: 1
Views: 2710
Reputation: 330063
You can simply use input$selectRunid
like this:
content(GET(
"http://stats", path="gentrap/alignments",
query=list(runIds=input$selectRunid, userId="dev")
add_headers("X-SENTINEL-KEY"="dev"), as = "parsed"))
It is probably wise to add some kind of action button and trigger download only on click.
Upvotes: 1