在SHILINE中使用Source() [英] using Source() in Shiny
本文介绍了在SHILINE中使用Source()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个工作R应用程序,我希望使用SHINY在线提供该应用程序。我的应用程序接收一个文件作为输入,所以客户端通过ui.R.server.R接收文件,然后我想调用我的应用程序。但是,当我使用source()时,myApp不知道我在server.R中收到的文件,并抛出错误:object not find。这是服务器的代码。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
(在我当前的应用中需要作为输入文件)。
推荐答案
若要在闪亮的应用程序中使用源代码,您需要调用local = TRUE
参数,因此在本例中:
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", local = TRUE)
}
})
})
这篇关于在SHILINE中使用Source()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文