Installing the R package

Filter Content By
Version
Languages

Installing the R package

To use our R interface, you'll need to install the Gurobi package in your local R installation. The R command for doing this is:

install.packages('<R-package-file>', repos=NULL)

The Gurobi R package file can be found in the <installdir>/R directory of your Gurobi installation (the default <installdir> for Gurobi 9.0.1 is /opt/gurobi901/linux64 for Linux, c:\gurobi901\win64 for 64-bit Windows, and /Library/gurobi901/mac64 for Mac). You should browse the <installdir>/R directory to find the exact name of the file for your platform (the Linux package is in file gurobi_9.0-1_R_3.6.1.tar.gz, the Windows package is in file gurobi_9.0-1.zip, and the Mac package is in file gurobi_9.0-1_R_3.6.1.tgz).

Depending on your local R environment you might need to install the R package slam. To do this, you should issue the following command within R:

install.packages('slam')


You will need to be careful to make sure that the R binary and the Gurobi package you install both use the same instruction set. For example, if you are using the 64-bit version of R, you'll need to install the 64-bit version of Gurobi, and the 64-bit Gurobi R package. This is particularly important on Windows systems, where the error messages that result from instruction set mismatches can be quite cryptic.

To run one of the R examples provided with the Gurobi distribution, you can use the source command in R. For example, if you are running R from the Gurobi R examples directory, you can say:

> source('mip.R')


If the Gurobi package was successfully installed, you should see the following output:

[1] 'Solution:'
[1] 3
[1] 1 0 1