title: R: Assign Variable Names based on a matrix's columns
body: <p>I am a (very) new user to R, and trying to replicate my MATLAB codes here (prefer R to Octave at this stage). </p>
  
  <p>I have the following matrix <code>df</code>:</p>
  
  <pre><code>variable value
  th   100
  tw   100
  gap  30
  </code></pre>
  
  <p>I'd like to be able to assign variables, based on the first column, to the values in the second.  So basically, <code>th = 100</code>, <code>tw = 100</code>, <code>gap = 30</code>. </p>
  
  <p>My end aim is to be able to manipulate the data in the following manner:</p>
  
  <pre><code>difference &lt;- th-gap
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>&gt;dput(df)
  structure(list(s = structure(1:3, .Label = c("aa", "bb", "cc" ), class = "factor"),
  n = c(2, 3, 5)), .Names = c("s", "n"), row.names = c(NA, -3L), class = "data.frame")
  </code></pre>