# GLPK/R

R is a free software environment for statistical computing and graphics. The R project is responsible for R. Packages for R are provided by the Comprehensive R Archive Network (CRAN). R is cross-platform and supported on Windows, MacOS X, and Linux.

In addition, R scripts (as can gnuplot scripts) can be use to process GLPK output directly, without the use of dedicated R packages.

## Rglpk[edit]

Package Rglpk is provided by CRAN — which also contains the reference manual.

To install from repository within R:

install.packages("Rglpk")

To install from local archive within R:

install.packages("Rglpk_0.6-0.tar.gz", repos = NULL, type="source")

Debian-based Linux users can also install Rglpk via the Debian package `r-cran-rglpk`. But it would pay to check on currency.

Rglpk provides two functions:

- Rglpk_read_file reads a linear problem from a file in either of the following formats: fixed MPS, free MPS, CPLEX, and GMPL.
- Rglpk_solve_LP solves a linear and mixed linear problems.

The following commands solve a problem provided in GMPL file */home/user/test.mod*

library(Rglpk) x <- Rglpk_read_file( "/home/user/test.mod", type = "MathProg", verbose = TRUE) Rglpk_solve_LP(x$objective, x$constraints[[1]], x$constraints[[2]], x$constraints[[3]], x$bounds, x$types, x$maximum)

## glpkAPI[edit]

The package glpkAPI has not been maintained since 2015.

## glpk[edit]

The deprecated package glpk has been archived by CRAN. It was based on GLPK 4.8 and never updated since 2006.