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.

Install and load required packages

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)

Compiler toolchain

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:

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.)

Install the RangeShiftR package

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.