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 13.0.2 the command would be:
install.packages('/opt/gurobi1302/linux64/R/gurobi_13.0-2_R_4.5.1.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/13.0/gurobi13.0.2_R.tar.gz
tar -xvzf gurobi13.0.2_R.tar.gz
cd gurobiR
make -f Makefile.macThis will produce a file named gurobi_13.0-2.tgz that should be used in the install command within R:
install.packages('<path to gurobi_13.0-2.tgz>', repos=NULL)