如果我以闪亮的方式运行脚本,则 R 脚本不会在 sqlite db 中写入 [英] R script do not write in sqlite db if I run the script in shiny
本文介绍了如果我以闪亮的方式运行脚本,则 R 脚本不会在 sqlite db 中写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数可以进行一些计算并将结果写入 sqlite 数据库.使用闪亮的应用程序,我可以看到结果,但是如果我查看数据库,则看不到它.有什么建议吗?交易
I have a function that do some calculation and write the result in a sqlite db. With a shiny application I see the result but if I look into the db I can not see it. Any suggestions? txs
举个例子
my_function = function(){
sometings
sqlAddDataToTable(db.file, result, tab.name)
return(result)
}
其中 sqlAddDataToTable 是一个函数,用于打开 db、附加 'result' 并关闭 db
where sqlAddDataToTable is a function that open db, append 'result' and close db
闪亮的我有
shinyServer(function(input, output){
X = reactive({ my_function() })
})
ps 如果我用 my_function 运行脚本,它就可以工作
ps If I run the script with my_function, it works
推荐答案
reactive
的内容需要有一个reactive input来启动函数.也许是这样的:
The contents of reactive
need to have a reactive input to initiate the function. Maybe something like:
shinyServer(function(input, output){
myReactives <- reactiveValues(myDF = my_function())
X = reactive({ myReactives$myDF })
})
x()
现在应该包含数据.
这篇关于如果我以闪亮的方式运行脚本,则 R 脚本不会在 sqlite db 中写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文