执行脚本 - [R编程 [英] Executing R script programmatically
问题描述
我有一个生成一些R代码里面一个C#程序。现在我保存脚本文件,然后复制/粘贴到R控制台。我知道有一个COM接口,R,但它似乎不符合的R(或2.7.8之后的任何版本)的最新版本工作。是否有某种方式保存到文件后,我可以通过编程执行从C#第r脚本?
I have a C# program that generates some R code. Right now I save the script to file and then copy/paste it into the R console. I know there is a COM interface to R, but it doesn't seem to work with the latest version of R (or any version after 2.7.8). Is there some way I can just programmatically execute the R script from C# after saving it to file?
推荐答案
要在C#中做到这一点你需要使用结果
壳(R CMD BATCH myRprogram.R)结果
请务必将您的情节像这样的结果
PDF(文件=myoutput .PDF)结果
地块(X,Y)结果
dev.off()结果
或形象包装结果
To do this in C# you'll need to use
shell (R CMD BATCH myRprogram.R)
Be sure to wrap your plots like such
pdf(file="myoutput.pdf")
plot (x,y)
dev.off()
or image wrappers
这篇关于执行脚本 - [R编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!