【发布时间】:2016-10-22 03:14:27
【问题描述】:
我需要允许用户上传文件来定义在应用中呈现的网络。
我想改变参数以重新渲染通过特殊闪亮 github 包部署的交互式闪亮图 - “rcytoscapejs”:https://github.com/cytoscape/r-cytoscape.js/tree/master
虽然图表部署良好,但我的问题是它只能从 UI 部署,独立于服务器...
g<-createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
#ui.R
dashboardBody(
sliderInput(inputId="num", label="Choose coef", value=2, min=1, max=3),
rcytoscapejs(g$nodes, g$edges)
)
正如您所看到的,当我尝试通过以下方式在服务器中实现代码时,这完全是从服务器中获得的:
#ui.R
graphOutput("graph")
#server.R
output$graph<-renderGraph({rcytoscapejs(g$nodes, g$edges)})
我尝试过“graphOutput”和“renderGraph”,但这些函数似乎不存在......
我尝试从 github 下载“renderGraph”。
devtools::install_github("mfontcada/renderGraph");
Downloading GitHub repo mfontcada/renderGraph@master
from URL https://api.github.com/repos/mfontcada/renderGraph/zipball/master
Error: Does not appear to be an R package (no DESCRIPTION)
但该软件包是 0.1 版,自 2014 年以来一直没有更新...
所以最终我的问题是如何改变驻留在“ui.R”代码中的东西的参数???
类似于以下内容,(文件上传代码取自:http://shiny.rstudio.com/gallery/file-upload.html):
server <- function(input, output) {
dataInput <- eventReactive(input$choices, {
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header, sep = input$sep, quote = input$quote)
createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
})
}
#ui.R
actionButton("choices", "Run analyses"),
fileInput('file1', 'Choose file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
),
rcytoscapejs(dataInput()$nodes, dataInput()$edges),
这当然会返回一个错误,因为不能在 ui.R 脚本中改变参数......
关于如何规避这个问题的任何提示?
【问题讨论】: