title: Subsetting a matrix, addressing colnames
body: <p>I have this document term matrix  from package R{tm} which i have coerced to <code>as.matrix</code>. MWE here:</p>
  
  <pre><code>&gt; inspect(dtm[1:ncorpus, intersect(colnames(dtm), thai_list)])
  &lt;&lt;DocumentTermMatrix (documents: 15, terms: 4)&gt;&gt;
  Non-/sparse entries: 17/43
  Sparsity           : 72%
  Maximal term length: 12
  Weighting          : term frequency (tf)
  
  Terms
  Docs toyota_suv gmotors_suv ford_suv nissan_suv
  1      0       1       0            0
  2      0       1       0            0
  3      0       1       0            0
  4      0       2       0            0
  5      0       4       0            0
  6      1       1       0            0
  7      1       1       0            0
  8      0       1       0            0
  9      0       1       0            0
  10     0       1       0            0
  </code></pre>
  
  <p>I need to subset this <code>as.matrix(dtm)</code>, such that I get only documents (rows) which refer to <code>toyota_suv</code> but no other vehicle. I get a subset for one term (toyota_suv) using  <code>dmat&lt;-as.matrix(dtm[1:ncorpus, intersect(colnames(dtm), "toyota_suv")])</code> which works well. How do I set up a query: documents where toyota_suv is non-zero but values of non-toyota_suv columns are zero? I could have specified column-wise as <code>==0</code> but this matrix is dynamically generated. In some markets, there may be four cars, in some markets there may be ten. I cannot specify colnames beforehand. How do I (dynamically) club all the non-toyota_suv columns to be zero, like all_others==0?
  Any help will be much appreciated.</p>