Kashif
Kashif

Reputation: 3327

what does this mean in Renviron?

I see a lot of stuff in my Renviron file like

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'}

And I'm confused. Why do we write R_LIBS_USER=${R_LIBS_USER-'~/R/aarch64-apple-darwin20-library/4.1'} instead of R_LIBS_USER='~/R/aarch64-apple-darwin20-library/4.1'? What does the former even mean?

Upvotes: 1

Views: 116

Answers (1)

user2554330
user2554330

Reputation: 44887

That's an example of POSIX shell variable expansion. The pattern ${variable-default} will expand to the value in variable if it is set, or it will expand to the default value if not. This is described in the ?Startup help page.

So you can set an environment variable named R_LIBS_USER to use your own customized libs, otherwise R will use ~/R/aarch64-apple-darwin20-library/4.1, and similarly for the other variables.

Upvotes: 1

Related Questions