Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自运行生成的rscript的R的跨平台系统调用_R_System - Fatal编程技术网

来自运行生成的rscript的R的跨平台系统调用

来自运行生成的rscript的R的跨平台系统调用,r,system,R,System,我正在尝试编写一个可以运行单独rscript的函数(在原始函数运行时启动一个闪亮的plot函数),但是跨平台问题是一个主要的难题。我想找到一种方法来避免以下代码中的“if windows==TRUE”语句。在不同的系统上,所需转义字符的差异似乎存在问题——到目前为止,我已经在ubuntu和windows上进行了测试 windows=FALSE tmpdir=tempdir() tmpdir=gsub('\\','/',tmpdir,fixed=TRUE) # tmpdir=gsub('\

我正在尝试编写一个可以运行单独rscript的函数(在原始函数运行时启动一个闪亮的plot函数),但是跨平台问题是一个主要的难题。我想找到一种方法来避免以下代码中的“if windows==TRUE”语句。在不同的系统上,所需转义字符的差异似乎存在问题——到目前为止,我已经在ubuntu和windows上进行了测试

windows=FALSE


tmpdir=tempdir()
tmpdir=gsub('\\','/',tmpdir,fixed=TRUE)
  # tmpdir=gsub('\\','\\/',tmpdir,fixed=TRUE)

wd<-  paste0("setwd('",tmpdir,"')")
writeLines(text=paste0(wd,'
  testout<-5
  save(testout,file=paste0("testout.rda"))
'),con=paste0(tmpdir,"/testscript.R"))

if(windows) system(paste0("Rscript --slave --no-restore -e source(\'",tmpdir,"/testscript.R\')"),wait=FALSE) else
  system(paste0("Rscript --slave --no-restore -e source\\(\\\'",tmpdir,"\\/testscript.R\\\'\\)"),wait=FALSE)
windows=FALSE
tmpdir=tempdir()
tmpdir=gsub('\\','/',tmpdir,fixed=TRUE)
#tmpdir=gsub('\\','\\/',tmpdir,fixed=TRUE)

Shiny的一个优点是它嵌入了一个web服务器。因此,您最好将您的应用程序作为web应用程序,托管在您自己的服务器上,从而在一个系统上只维护一份代码。闪亮部分只是软件包的一小部分,用于在优化/采样过程中进行绘图。您能定义一个函数来构建路径和“隐藏”吗那里的操作系统检查?是的,我可以做一系列操作系统检查,然后在每个操作系统上进行测试-我希望/要求提供某种通用解决方案,避免操作系统特定的检查,并且可以正常工作!