title: How to convert column types in R tidyverse
body: <p>I'm trying to get comfortable with using the Tidyverse, but data type conversions are proving to be a barrier. I understand that automatically converting strings to factors is not ideal, but sometimes I would like to use factors, so some approach to easily converting desired character columns in a tibble to factors would be excellent. I prefer to read in excel files with the readxl package, but factors aren't a permitted column type! I can go through column by column after the fact, but that's really not efficient. I want either of these two following things to work:</p>
  
  <ol>
  <li><p>Read in a file and simultaneously specify which columns should be read as factors:</p>
  
  <pre><code> data &lt;- read_excel(path = "myfile.xlsx", 
                      col_types=c(col2="factor", col5="factor)))
  </code></pre></li>
  <li><p>Or this function would be excellent for many reasons, but I can't figure out how it's supposed to work. The col_types function is very confusing to me:</p>
  
  <pre><code> diamonds &lt;- col_types(diamonds, 
                         cols=c(cut="factor", color="factor", clarity="factor"))
  </code></pre></li>
  </ol>
  
  <p>Thanks in advance!</p>