title: dplyr/r make class spec_tbl_df
body: <p>I'm trying to run a line of code that reads over 55 columns. 20 of them have distances of the location from other cities. This code looks for the shortest distance and populates a new column with the name of the city that has the shortest distance from the location. I'm running the code on two nearly identical datasets, except the first one has many more columns than the second.</p>
  
  <pre><code>Enrollment_Report$nearest_hub &lt;- hub_locations_list$hub_loc[apply(Enrollment_Report[grep("^dist", names(Enrollment_Report))], 1, which.min)]
  </code></pre>
  
  <p>It yields this error, but only with the first dataset:</p>
  
  <pre><code>  invalid subscript type 'list'
  </code></pre>
  
  <p>The issue is that this code works with one data set and not another. The code has no typos, and with the first dataset, it the class looks like:</p>
  
  <pre><code>class(Enrollment_Report)
  [1] "tbl_df"     "tbl"        "data.frame"
  </code></pre>
  
  <p>But the second dataset, that the code works on, is this class:</p>
  
  <pre><code>class(all_employee_locations)
  [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"
  </code></pre>
  
  <p>My question: how do I get the first dataset to be class spec_tbl_df? I don't know why R reads in the second dataset automatically this way, and  I can't find any function to make it read it in this way.</p>
  
  <p>It's important that I make this class explicit because this code went from working to suddenly not working (even after resetting my session).</p>