title: Converting a dataframe of label/values to a named numeric vector
body: <p>I am trying to convert a dataframe with labels/values to a named numeric vecotr.
  For example I have the following dataframe  </p>
  
  <pre><code>&gt;df=data.frame(lab=c("A","B","C","D"),values=c(1,2,3,4))  
  &gt; df  
     lab values  
  1   A      1  
  2   B      2  
  3   C      3  
  4   D      4  
  </code></pre>
  
  <p>So what I am trying to do is to iterate or use a function on this data frame to get the following  </p>
  
  <pre><code>&gt;v_needed=c("A"=1,"B"=2,"C"=3,"D"=4)  
  &gt; v_needed  
  A B C D   
  1 2 3 4 
  </code></pre>
  
  <p>I tried to convert this to a factor but it didn't give the desired output</p>
  
  <pre><code>&gt;v_failure=factor(df$values,labels=df$lab)
  </code></pre>