r-这在Renviron中意味着什么



我在Renviron文件中看到了很多东西,比如

MAKE=${MAKE-'make'}
## Prefer a POSIX-compliant sed on e.g. Solaris
SED=${SED-'/usr/bin/sed'}
## Prefer a tar that can automagically read compressed archives
TAR=${TAR-'/usr/bin/tar'}
## System and compiler types.
R_SYSTEM_ABI='macos,gcc,gxx,gfortran,gfortran'
## Strip shared objects and static libraries.
R_STRIP_SHARED_LIB=${R_STRIP_SHARED_LIB-'strip -x'}
R_STRIP_STATIC_LIB=${R_STRIP_STATIC_LIB-'strip -S'}
R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}

我很困惑。为什么我们写R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'}而不是R_LIBS_USER='~/R/aarch64-apple-darwin20-library/4.1'?前者到底是什么意思?

这是POSIX外壳变量扩展的一个例子。如果设置了模式${variable-default},它将扩展到variable中的值;如果没有设置,它将展开到default中的值。?Startup帮助页对此进行了说明。

因此,您可以设置一个名为R_LIBS_USER的环境变量来使用您自己的自定义库,否则R将使用~/R/aarch64-apple-darwin20-library/4.1,其他变量也将使用类似的方法。

最新更新