Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.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
R windows上的Gnu make更改搜索路径_R_Linux_Windows_Makefile_Knitr - Fatal编程技术网

R windows上的Gnu make更改搜索路径

R windows上的Gnu make更改搜索路径,r,linux,windows,makefile,knitr,R,Linux,Windows,Makefile,Knitr,我正在用knitr和latex在linux上编写一个文档。我制作了一个小的makefile来自动化构建。它在linux上运行得非常好,但在windows上却有问题。让我得到 C:\Users\samde_000\Documents\GaussianProcess-Course>make mkdir -p build && \ cp src/GPcourse.Rnw build/GPcourse.Rnw && \ cd build &&

我正在用knitr和latex在linux上编写一个文档。我制作了一个小的makefile来自动化构建。它在linux上运行得非常好,但在windows上却有问题。让我得到

C:\Users\samde_000\Documents\GaussianProcess-Course>make
mkdir -p build && \
    cp src/GPcourse.Rnw build/GPcourse.Rnw && \
    cd build && \
    Rscript -e "library(knitr); knit(\"GPcourse.Rnw\")"
Error in library(knitr) : there is no package called 'knitr'
Execution halted
所以我检查了这个以确定问题:

C:\Users\samde_000\Documents\GaussianProcess-Course>Rscript -e ".libPaths()"
[1] "C:/Users/samde_000/Documents/R/win-library/3.2"
[2] "C:/Program Files/R/R-3.2.2/library"

C:\Users\samde_000\Documents\GaussianProcess-Course>Rscript -e "library(knitr)"
因此,在使用make时,无法找到包。但是手动发出相同的命令,就可以找到包

为了绝对确保差异是由于使用make造成的,我稍微修改了Makefile以输出R搜索路径:

C:\Users\samde_000\Documents\GaussianProcess-Course>make
mkdir -p build && \
    cp src/GPcourse.Rnw build/GPcourse.Rnw && \
    cd build && \
    Rscript -e ".libPaths()" && \
    Rscript -e "library(knitr); knit(\"GPcourse.Rnw\")"
[1] "C:/Program Files/R/R-3.2.2/library"
Error in library(knitr) : there is no package called 'knitr'
Execution halted
这表明make发出命令时。搜索路径以某种方式更改为仅包含
“C:/Program Files/R/R-3.2.2/library”

如果我是正确的,在一个子shell中发布所有食谱。也许这是在制造麻烦?总之,我对windows没有太多经验,我不知道如何在使用make时保持相同的R搜索路径


我之所以问这个问题,是因为一位合著者在windows上工作。因此,makefile应该与linux和windows兼容。

您是否将
C:/Users/samde_000/Documents/R/win library/3.2
添加到一些shell启动文件或类似文件中的R libpath中?至少我不知道。但也许是某个安装人员帮我做的。这可能吗?诚然,我对makefiles基本一无所知,但我想使用makefile时,
Rscript
可能会在不同的用户帐户下启动。您可以通过在makefile内外执行
echo%username%
来验证这一点。当然可能。您是从
cmd.exe
、cygwin shell还是其他什么地方运行此命令?
echo%username%
cmd.exe
shell中键入命令时会打印我的用户名,但从makefile打印时只会再次返回
%username%
。换句话说,
username
变量不存在。