【发布时间】:2014-03-18 20:18:44
【问题描述】:
我有一个可用的 R 应用程序,我想使用 Shiny 在线提供。我的应用程序接收一个文件作为输入,因此客户端通过 ui.R 上传文件。 server.R 接收文件,然后我想调用我的应用程序。但是,当我使用 source() 时,myApp 不知道我在 server.R 中收到的文件并抛出 error : object not found。这是服务器的代码。R
shinyServer(function(input, output) {
output$contents <- renderTable({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
else{
tdata <- as.matrix(read.table(inFile$datapath))
head(tdata, n = 2)
source("./CODE/run_myApp.r")
}
})
})
但是,myApp 不包含tdata(在我当前的应用程序中需要它作为输入文件)。
【问题讨论】:
-
尝试使用
source("./CODE/run_myApp.r", local = TRUE) -
这部分需要
isolate。isolate({source("./CODE/run_myApp.r")}) -
@jdharrison 谢谢,现在可以使用了
-
@Elahehkamaliha 您能否将下面 jdharrison 的答案标记为答案?