我现在正在使用闪亮的软件包几个小时,并希望创建一个选择输入窗口小部件,使我能够从服务器下载某个数据集。所以我找到了一种方法来获取包含我下载所有ID的数据框:
> 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
在这个数据帧之外,我解析了一个包含来自df的Runids的selectInput框,如下所示:
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>
现在我希望能够从selectInput()
输出中提取值。这样我就可以从服务器中检索正确的数据文件。
input$selectRunid == <value> {
Jin <- content(GET("http://stats/gentrap/alignments?runIds=<MYRUNID>&userId=dev",
add_headers("X-SENTINEL-KEY" = "dev"), as = "parsed"))}
任何提示都表示赞赏!
答案 0 :(得分:1)
您可以像这样简单地使用input$selectRunid
:
content(GET(
"http://stats", path="gentrap/alignments",
query=list(runIds=input$selectRunid, userId="dev")
add_headers("X-SENTINEL-KEY"="dev"), as = "parsed"))
添加某种操作按钮并仅在点击时触发下载可能是明智的。