且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在R中运行异步功能

更新时间:2023-02-18 13:39:36

最终,我停止了以下解决方案:

Eventually I stopped on the following solution:

Rpath <- Find(file.exists, c(commandArgs()[[1]], file.path(R.home("bin"), commandArgs()[[1]]),
                             file.path(R.home("bin"), "R"), file.path(R.home("bin"), "Rscript.exe")))
out <- system('%s --no-save --slave -e \"Your R code here\" ', wait=FALSE)

第一行搜索R可执行文件的路径,第二行从命令行环境执行R代码,而不等待结果.

The first line searches for the path of R executable, and the second executes R code from the command-line environment not waiting for result.