title: Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "NULL"
body: <p>I get a strange error when <code>knitting</code> this R Markdown into an HTML file. I think it has to do with some sort of incompatibility in the <code>dplyr</code> package with <code>knitr</code>.</p>
  
  <p><strong>UPDATE: I replaced the <code>cbind</code> chunk with the <code>dplyr::bind_cols</code> command, as someone suggested below not to use <code>cbind</code> with <code>dplyr</code>. However, I now get a different, equally incomprehensible error:</strong></p>
  
  <p><code>library(dplyr)
  counts.all &lt;- bind_cols(count.tables[["SF10281"]], count.tables[["SF10282"]])</code></p>
  
  <p>The error I get with this change (again, only when knitting):</p>
  
  <p><code>Error in eval(expr, envir, enclos) : not compatible with STRSXP
  Calls: &lt;Anonymous&gt; ... withVisible -&gt; eval -&gt; eval -&gt; bind_cols -&gt; cbind_all -&gt; .Call</code></p>
  
  <hr>
  
  <p><strong>Previous error with <code>cbind</code> instead of <code>dplyr::bind_cols</code>:</strong></p>
  
  <p>Running the chunks separately works fine, and I was able to <code>knit</code> fine until I added the last chunk (using <code>select</code> from <code>dplyr</code>).</p>
  
  <p><strong>This is the error I get:</strong></p>
  
  <pre><code>Quitting from lines 75-77 (Analysis_SF10281_SF10282_Sep29_2015.Rmd) 
  Error in UseMethod("select_") : 
    no applicable method for 'select_' applied to an object of class "NULL"
  Calls: &lt;Anonymous&gt; ... withVisible -&gt; eval -&gt; eval -&gt; &lt;Anonymous&gt; -&gt; select_
  </code></pre>
  
  <p><strong>This is the entire Rmd file:</strong></p>
  
  <p>Read-in gene count tables into a single list of data frames (one data frame per sample):</p>
  
  <pre><code>```{r}
  count.files &lt;- list.files(pattern = "^SF[0-9]+_counts.txt$")
  
  count.tables &lt;- lapply(count.files, read.table, header=T, row.names=1)
  
  names(count.tables) &lt;- gsub("\\_counts.txt", "", count.files)
  ```
  </code></pre>
  
  <p>Remove gene metadata columns:</p>
  
  <pre><code>```{r}
  count.tables &lt;- lapply(count.tables, `[`, -(1:5))
  ```
  </code></pre>
  
  <p>Rename cells (columns) to short version:</p>
  
  <pre><code>```{r}
  count.tables &lt;- lapply(count.tables, function(x) {names(x) &lt;- gsub("X.diazlab.aaron.tophat_out.SF[0-9]+.Sample_(SF[0-9]+).[0-9]+.([A-Z][0-9]+).accepted_hits.bam", "\\1-\\2", names(x)); x})
  ```
  </code></pre>
  
  <p>Save object to file for later:
      <code>{r}
      saveRDS(count.tables, file="gliomaRawCounts_10281_10282_10345_10360.rds")
  </code></p>
  
  <p>Make a single data frame with all 4 samples (384 cells), and write to text file:</p>
  
  <pre><code>```{r}
  counts.all &lt;- cbind(count.tables[["SF10281"]], count.tables[["SF10282"]], count.tables[["SF10345"]], count.tables[["SF10360"]])
  
  write.table(counts.all, file="gliomaRawCounts_10281_10282_10345_10360.txt", sep="\t", quote=F, col.names=NA)
  ```
  </code></pre>
  
  <p>Read metadata.
  Do not assign cell ID column as row.names, for compatibility with dplyr.</p>
  
  <pre><code>```{r}
  meta &lt;- read.delim("QC_metrics_SCell_SF10281_SF10282_SF10345_SF10360.txt", check.names = F, stringsAsFactors = F)
  ```
  </code></pre>
  
  <p>Filter cells based on live/dead/multi calls.
  Exclude empty, red-only, and multi-cell wells:</p>
  
  <pre><code>```{r, results='hide', message=FALSE, warning=FALSE}
  library(dplyr)
  meta.select &lt;- filter(meta, grepl("^1g", `Live-dead_call`))
  ```
  </code></pre>
  
  <p>Filter cells based on 1,000 gene threshold:</p>
  
  <pre><code>(Includes 12 'FAIL' cells)
  ```{r}
  meta.select &lt;- filter(meta.select, Genes_tagged &gt; 1000)
  ```
  </code></pre>
  
  <p>Subset counts table to include only cells that passed QC.</p>
  
  <pre><code>```{r}
  counts.select &lt;- dplyr::select(counts.all, one_of(meta.select$ID))
  head(counts.select[,1:10])
  ```
  </code></pre>