title: R: Automatically convert column types based on the values
body: <p>I have a tibble with lots of columns. I don't want to change them one by one. Let's say that tible looks like this:</p>
  
  <pre><code>df &lt;- tibble(
    x = c(1,0,1,1,'a'), 
    y = c('A', 'B', 1, 'D', 'A'), 
    z = c(1/3, 4, 5/7, 100, 3)
  )
  </code></pre>
  
  <p>I want to convert their column types based on value in other tibble:</p>
  
  <pre><code>df_map &lt;- tibble(
    col = c('x','y','z'), 
    col_type = c('integer', 'string', 'float')
  )
  </code></pre>
  
  <p>What's the most appropriate solution? </p>