title: Constrained max using Rglpk in R, not conformable
body: <p>I have a question regarding constrained maximization using the Rglpk packaged in R.  </p>
  
  <p>In the code below, we generate a dataframe 'df'.  I am trying to max the sum of column z, subject to:</p>
  
  <ul>
  <li>The COUNT of the total number of F's to be >= 3 and &lt;=5</li>
  <li>The COUNT of the total number of G's to be >= 3 and &lt;=5</li>
  <li>The TOTAL COUNT of F's and G's to be == 8</li>
  <li>The SUM of column y not exceeding some number (in the code I have it set to 50,000).</li>
  </ul>
  
  <p>Not sure where I am going wrong...However, I may be way off as of right now. I have been banging my keyboard for the better part of 2 days.  </p>
  
  <pre><code>    library(random)
      library(Rglpk)
      library(data.table)
      w&lt;-c( "F","G","G","F","F","G","F","G",
        "G","F","G","G","F","G","G","F",
        "G","F","F","F","G","G","F","G",
        "F","G","F","F","G","F","F","F",
        "G","F","G","G","F","G","F","G")
      x&lt;-randomStrings(n=40, len=3, digits=F, upperalpha=F,loweralpha=T, unique=T)
      y&lt;-c("8100",  "8000",  "7900",  "7800", "7700", "7400", "7300", "7200", "7100", "6700",
       "6500",    "6100", "6000", "5800", "5800", "5600", "5400", "5200", "5000", "4900",
       "4800",    "4200", "4100", "4100", "3900", "3800", "3700", "3400", "3300", "3200",
       "3000",    "3000", "3000", "3000", "3000", "3000", "3000", "3000", "3000", "3000")
      z&lt;-c( "27.85","25.057", "24.588",   "23.893",   "23.284",   "24.071",   "24.864",   "22.525",   "23.15",    "22.023",
        "24.803", "18.284",   "19.675",   "20.138",   "16.179",   "20.6", "17.821",   "16.333",   "16.659",   "16.013",   
        "14.947", "10.262",   "15.425",   "10.989",   "11.556",   "11.429",   "11.3", "10.682",   "9.542",    "4.727",    
        "7.162",  "5.053",    "3.706",    "8.604",    "10.868",   "8.638",    "7.167",    "3.333",    "2.833",    "7.662")
      df &lt;- as.data.frame(cbind(w,x,y,z))
      setnames(df, old = c('w','V1','y','z'), new = c('w','x','y','z'))
      rm(w,x,y,z)
      num.x &lt;- length(df$x)
          obj &lt;- df$z
      var.types &lt;- rep("B", num.x)
      matrix &lt;- rbind(as.numeric(df$w == "G"), # num G
                  as.numeric(df$w == "F"), # num F
              as.numeric(df$w %in% c("G", "F")),  # Num G/F
                  df$y)  
      direction &lt;- c("&gt;=",
             "&lt;=",
             "&gt;=",
             "&lt;=",
             "==",
             "&lt;=")
      rhs &lt;- c(3, 
       5, 
       3, 
       5, 
       8, 
       50000)                
  
      sol &lt;- Rglpk_solve_LP(obj = obj, mat = matrix, dir = direction, rhs = rhs,
                    types = var.types, max = TRUE)
  </code></pre>