title: Linear Programs using R
body: <p>How can we solve a linear program using R? I want to solve the following example:</p>
  
  <pre><code>min -a -2b +4c
  
  Constraints
  a + b + s1 = 5
  a + 3c -s2 = 10
  2b - 3c = 20
  
  a &gt;= 0, b &gt;= 0, c &gt;= 0, s1 &gt;= 0, s2 &gt;= 0
  </code></pre>
  
  <p>The equations might not make total sense. I just need to know the syntax of writing these equations in R.
  I might write something like this for the above equations</p>
  
  <pre><code>require(lpSolve)
  
  R.obj &lt;- c(-1,-2,4)
  
  R.con &lt;- matrix(c(1,1,1,1,3,-1,2,-3),nrow=3,byrow=TRUE)
  
  R.dir &lt;- c("=","=","=")
  
  R.rhs &lt;- c(5,10,20)
  
  lp("min",R.obj,R.con,R.dir,R.rhs)
  </code></pre>
  
  <p>Would this be correct? In the documentation, the matrix is always <code>M*M</code>, what if the matrix is <code>M*N</code> where <code>N != M</code>?</p>