尝试在 ant 中使用 exec 可执行文件到 运行 R

Trying to use exec executable in ant to run R

我在实验中使用了以下图像 J 的开源版本:

https://github.com/pcj/arterioj

它使用 ANT。

其中的蚂蚁目标是: 统计数据

 <!-- ================================================================ -->     
 <!-- Stats and plot generation tasks -->
<!-- ================================================================ -->

 <target name="stats">
<exec executable="R">
  <arg line="--vanilla --no-readline --quiet --slave --file=${basedir}/ldip-data.R --args"/>
</exec>
</target>

当我尝试使用此目标时,我收到以下构建错误消息:

构建失败 /Users/James/ArterioJ/build.xml:179:执行失败:java.io.IOException:无法运行程序"R"(在目录“/Users/James/ArterioJ”中):错误=2 , 没有那个文件或目录

我不确定如何解决这个问题。我试图将 R 包复制到 /users/James/ArterioJ 目录中,看看是否有帮助,但没有效果。

谢谢

您可能想要指定 R 可执行文件的完整路径,例如:

<property name="r.home" value="/home/me/R_INSTALL"/>

<target name="stats">
  <exec executable="${r.home}/R">
    <arg line="--vanilla --no-readline --quiet --slave --file=${basedir}/ldip-data.R --args"/>
  </exec>
</target>

或者,如果可执行文件的路径是 PATH 环境变量的一部分,您可以将 searchpath="true" 属性添加到 exec 任务:

  <exec executable="R" searchpath="true">
    <arg line="--vanilla --no-readline --quiet --slave --file=${basedir}/ldip-data.R --args"/>
  </exec>

这是 Ant documentation about searchpath 的摘录:

When this attribute is true, then system path environment variables will be searched when resolving the location of the executable