To begin, you'll need to install the Gurobi package in R. The R command for doing this is:
install.packages('<R-package-file>', repos=NULL)
The R package file can be found in the <installdir>/R directory of your Gurobi installation.
For a default Linux installation of Gurobi 14.0.0 the command would be:
install.packages('/opt/gurobi1400/linux64/R/gurobi_14.0-0_R_4.6.0.tar.gz', repos=NULL)You will need to adjust the path to match your installation directory and version.
Ensure that both the R binary and the Gurobi package are compatible with the same instruction set. To use the Gurobi R package, you must use the 64-bit version of R.
If you are using R from RStudio Server and you get an error indicating that R is unable to load the Gurobi shared object, you may need to set the rsession-ld-library-path entry in the server config file. Please consult the RStudio documentation for more information.
Note: The macOS R packages for Gurobi version 12.0 and higher are incompatible with older macOS machines with x86_64 architecture. In this case, try the following:
Open a terminal on your macOS machine, navigate to a folder of your choosing (such as your home directory) and run the following commands:
wget https://packages.gurobi.com/14.0/gurobi14.0.0_R.tar.gz
tar -xvzf gurobi14.0.0_R.tar.gz
cd gurobiR
make -f Makefile.macThis will produce a file named gurobi_14.0-0.tgz that should be used in the install command within R:
install.packages('<path to gurobi_14.0-0.tgz>', repos=NULL)