title: Consistently subset matrix to a vector and avoid colnames?
body: <p>I would like to know if there is R syntax to extract a column from a matrix and <em>always</em> have no name attribute on the returned vector (I wish to rely on this behaviour).</p>
  
  <p>My problem is the following inconsistency:</p>
  
  <ul>
  <li>when a matrix has more than one row and I do <code>myMatrix[, 1]</code> I will get the first column of <code>myMatrix</code> with no name attribute. This is what I want.</li>
  <li>when a matrix has <strong>exactly one row</strong> and I do <code>myMatrix[, 1]</code>, I will get the first column of <code>myMatrix</code> <strong>but it has the first colname as its name</strong>.</li>
  </ul>
  
  <p>I would like to be able to do <code>myMatrix[, 1]</code> and <em>consistently</em> get something with <strong>no name</strong>.</p>
  
  <p>An example to demonstrate this:</p>
  
  <pre><code># make a matrix with more than one row,
  x &lt;- matrix(1:2, nrow=2)
  colnames(x) &lt;- 'foo'
  #      foo
  # [1,]   1
  # [2,]   2
  
  # extract first column. Note no 'foo' name is attached.
  x[, 1]
  # [1] 1 2
  
  # now suppose x has just one row (and is a matrix)
  x &lt;- x[1, , drop=F]
  # extract first column
  x[, 1]
  # foo    # &lt;-- we keep the name!!
  #   1
  </code></pre>
  
  <p>Now, the documentation for <code>[</code> (<code>?'['</code>) mentions this behaviour, so it's not a bug or anything (although, why?! why this inconsistency?!):</p>
  
  <blockquote>
    <p>A vector obtained by matrix indexing will be unnamed <strong>unless ‘x’ is one-dimensional</strong> when the row names (if any) will be indexed to provide names for the result.</p>
  </blockquote>
  
  <p><strong>My question is</strong>, is there a way to do <code>x[, 1]</code> such that the result is  <em>always</em> unnamed, where <code>x</code> is a matrix?</p>
  
  <p>Is my only hope <code>unname(x[, 1])</code> or is there something analogous to <code>[</code>'s <code>drop</code> argument? Or is there an option I can set to say "always unname"? Some trick I can use (somehow override <code>[</code>'s behaviour when the extracted result is a vector?)</p>