title: Get a single value from a data frame in R
body: <p>Say I have a data frame df such as :</p>
  
  <pre><code>col1 col2
  x1   y1
  x2   y2
  </code></pre>
  
  <p>with arbitrary values in each "cell".
  How do I get a single value for a given cell ? </p>
  
  <p>For instance to get the value of the cell in the first row and second column, doing this :</p>
  
  <pre><code>df[1,2]
  </code></pre>
  
  <p>works with numeric values, but with strings it return the levels as well.</p>
  
  <p>What is the proper way of getting a single value (for instance for use in a condition for a subset of another data frame) ?</p>
  
  <p><strong>EDIT</strong>
  More details about what I need this for. Say I need to use values from df to subset another data frame df2 :</p>
  
  <pre><code>subset(df2, (id == SomeCommand(df[1,1])) &amp; (name == SomeCommand(df[1,2])))
  </code></pre>
  
  <p>Is there any such "SomeCommand" that would reliably return a single value (w/o levels) of the appropriate type regardless of the type of the columns in df ?</p>