From CRAN

Stable releases are published on CRAN. CRAN provides binaries for Windows and macOS, so no compiler is needed on those platforms. Linux installs compile from source.

install.packages("randomForestSRC")

From GitHub

The development version lives on the main branch of kogalur/randomForestSRC. It contains bug fixes and new features ahead of the next CRAN release. Building it requires a C compiler that R can use. Install Rtools on Windows or the Xcode command line tools on macOS. Linux distributions provide gcc through their package manager.

# install.packages("remotes")
remotes::install_github("kogalur/randomForestSRC")

The package can also be installed from a local clone.

git clone https://github.com/kogalur/randomForestSRC
R CMD INSTALL --preclean --clean randomForestSRC

Confirm the installed version.

packageVersion("randomForestSRC")

OpenMP

randomForestSRC grows trees, predicts and computes variable importance in parallel with OpenMP. The CRAN binaries for Windows and macOS include OpenMP support. A source build takes OpenMP from the compiler.

  • Linux. gcc supports OpenMP by default.
  • Windows. Rtools supports OpenMP by default.
  • macOS. Apple clang ships without the OpenMP runtime. Install the libomp runtime from the R project’s macOS OpenMP page, choosing the build that matches your Xcode version, then add two lines to ~/.R/Makevars.
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp

Homebrew’s libomp also works. Point the same two lines at its headers and library. The prefix is /opt/homebrew/opt/libomp on Apple silicon and /usr/local/opt/libomp on Intel Macs.

CPPFLAGS += -Xclang -fopenmp -I/opt/homebrew/opt/libomp/include
LDFLAGS += -L/opt/homebrew/opt/libomp/lib -lomp

Recheck ~/.R/Makevars after upgrading R, macOS or Xcode.

The number of cores used by the package is set with options(rf.cores = ...). See the Parallel Processing vignette.

The Apache Spark Package

To create the Apache Spark package using the GitHub repository, you will need the following tools: Apache Ant (v1.10), Java JDK (v1.80), Scala (v2.12), and Apache Maven (v3.5). You must also have Apache Spark (v2.1) installed.

After obtaining and unzipping the source code from the GitHub respository, from the top-level directory (the directory containing build.xml), the command

ant

will give you several options. The command

ant source-spark

will create the Spark source code package directory-tree ./target/spark/. To compile the the source code package, type

ant build-spark.

This will create the Spark target package directory-tree ./target/spark/target/. A sample helloRandomForestSRC program can be executed by changing to the directory ./target/spark/target/ and typing ./hello.sh or ./hello.cmd according to your operating system. The source code for the example is located in our GitHub repository. It does little more than start a Spark session, grow a forest, and stop the Spark session. Details of raw unformatted ensemble information is presented in a log file rfsrc-x.log in the users HOME directory, though they are not available for examination by the user at this point in any coherent way.

The Java API Specification for randomForestSRC is avaliable. It is purely skeletal at this point, but will be flushed out in more detail in the near future.



Cite this vignette as
H. Ishwaran, M. Lu, and U. B. Kogalur. 2021. “randomForestSRC: installing randomForestSRC vignette.” http://randomforestsrc.org/articles/installation.html.

@misc{HemantInstall,
    author = "Hemant Ishwaran and Min Lu and Udaya B. Kogalur",
    title = {{randomForestSRC}: installing {randomForestSRC} vignette},
    year = {2021},
    url = {http://randomforestsrc.org/articles/installation.html},
    howpublished = "\url{http://randomforestsrc.org/articles/installation.html}",
    note = "[accessed date]"
}