The RangeShiftR
package source is publicly released on a
github
repository as a beta version (it is not available on CRAN).
For further information please contact us under RangeShiftR@uni-potsdam.de.
As of yet, RangeShiftR
has to be built from source by
the user. This requires the R
-version 3.6.0 or
higher, the packages Rcpp
1.0.1 or higher and
Rdpack
0.7 or higher, as well as a functional C++
toolchain (see below). Further, the package devtools
is
recommended for an easy installation directly from github.
Install these packages if you don’t have them already.
library(Rcpp)
library(devtools)
library(Rdpack)
In order to build the package from source, we need to set up a
compiler toolchain. This involves installing a suitable C++ compiler and
making it available to R
. The exact procedure depends on
your operating system as well as your R installation. Unix-based systems
like Linux or MacOS might have the toolchain set up already along with
the installation of R. You can find detailed instructions here: https://thecoatlessprofessor.com/programming/installing-rtools-for-compiled-code-via-rcpp/
Here is an outline of the information from this website:
on Windows: the Rtools
package on CRAN contains all
the required tools. Find installing instructions for either manual
installation (top) or from within R
(further down) on the
website mentioned above. (Tip: Pay extra attention to steps
10/11.)
If you have upgraded to R
version 4, make sure to
install the corresponding Rtools40
. More information here:
https://cran.r-project.org/bin/windows/Rtools/ (Tip: Pay
extra attention to the instructions on the bottom of the page, regarding
the path variable.)
on Linux: Install the standard R
development
packages (e.g. on Ubuntu and Debian: r-base-dev
).
on MacOS: Install the Apple Developer Tools Xcode
and the C++ compiler clang7
. Find installing instructions
here (for RangeShiftR
, the Fortran compiler
gfortran is not needed, so you may leave this step out): https://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-macos/
You can check if everything works properly by trying this in your
R
terminal:
Rcpp::evalCpp("2+2")
## [1] 4
If the output is not 4, then there is an issue with the toolchain.
One common reason for this can be that R
doesn’t find
the C++ compiler due to an inappropriately set path variable. In this
variable your system stores the paths in which to look for executables
like the compiler (e.g. gcc or clang), in the order in
which they appear in the path variable.
You can try and check if the path to the directory that contains your
compiler is part of the path variable.
For example, on Windows 10: Go to Control panel -> System and
Security -> System -> Advanced system settings -> Environmental
variables.
In the list of system variables, look for ‘Path’. If the correct path is
missing, you can add it manually:
Click ‘edit’ on the ‘Path’ variable -> add the correct variable (The
two standard paths would be ‘C:\Rtools\bin’ and
‘C:\Rtools\mingw_32\bin’; you can also try moving them up on the list so
they get searched first.)
Now, if all preparations are done and successful, we can install the
package directly from its public repository on github, using
devtools
:
devtools::install_github("https://github.com/RangeShifter/RangeShiftR-pkg", ref = "main", subdir="RangeShiftR")
After successful installation, which can take a few minutes, you can load and use the package:
library(RangeShiftR)
## RangeshiftR version 1.0.4 (10.05.2022)
## Copyright (C) 2020-2022 Anne-Kathleen Malchow, Greta Bocedi, Stephen C.F. Palmer, Justin M.J. Travis, Damaris Zurell
##
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
## You are welcome to redistribute it and/or modify it under certain conditions;
## type 'RangeShiftR_license()' for details.
If questions or problems remain, please let us know via the github Forum.