title: Changing multiple columns of a data frame from class 'character' to class 'time' using chron
body: <p>I have a data frame with multiple columns, some of which I need to change to 'time' class using <code>chron</code> so that I can retrieve basic statistics. These columns are currently times stored as characters and formatted like this: hh:mm.</p>
  
  <p>Here is a subset of it as well as the list of columns that need to change:</p>
  
  <pre><code>    &gt; Data
       DATE FLT TYPE    REG   AC  DEP  ARR   STD   STA   ATD   ATA
  1 15-01-02 953   J  C-GCPT 73M  YVQ  YEV  12:00 12:55 13:00 13:59
  2 15-01-04 953   J  C-GCPT 73M  YVQ  YEV  12:00 12:55 13:17 14:13
  3 15-01-05 953   J  C-GCPT 73M  YVQ  YEV  12:00 12:55 13:20 14:14
  
  Time_list &lt;-c("STD","STA","ATD","ATA")
  </code></pre>
  
  <p>Here is what I have done to change only one column (and it works):</p>
  
  <pre><code>    Data$ATA &lt;- paste0(Data$ATA, ':00')
      Data$ATA&lt;-chron(times.=Data$ATA)
  
      class(Data$ATA)
      [1] "times"
  </code></pre>
  
  <p>However, I would prefer to be able to do all the columns at the same time since there are many of them. I've tried multiple techniques and some seem to work for the first part, which is pasting ':00', but it always goes wrong for the second part, using <code>chron</code> . I seem to have a length problem that I don't understand</p>
  
  <ol>
  <li><p>Using <code>dmap</code> </p>
  
  <pre><code>Data[,Time_list]&lt;-
    Data%&gt;%
    select(one_of(Time_list)) %&gt;%
    dmap(paste0,':00')
  
  Data[,Time_list]&lt;-
    Data %&gt;%
    select(one_of(Time_list)) %&gt;%
    dmap(chron,times.=Data[,Time_list])
  
  **Error in .f(.d[[i]], ...) : 
    .d[[i]] and Data[, Time_list] must have equal lengths**
  </code></pre></li>
  <li><p>Using <code>apply</code></p>
  
  <pre><code>YEVdata[,(Time_list)] &lt;- lapply(YEVdata[,(Time_list)], paste0,':00')
  Data[,(Time_list)] &lt;- lapply(Data[,(Time_list)], chron, times. =Data[,(Time_list)])
  **Error in FUN(X[[i]], ...) : 
    X[[i]] and Data[, (Time_list)] must have equal lengths**
  </code></pre></li>
  <li><p>Using a <code>for</code>loop</p></li>
  </ol>
  
  <p>I tried using a for loop, but I'm just a beginner and could get anywhere.</p>
  
  <ol start="4">
  <li>Using "simple" solution from another Stack Overflow question.</li>
  </ol>
  
  <p>It just made a mess, even pasting.</p>
  
  <p><a href="https://stackoverflow.com/questions/17453440/efficiently-transform-multiple-columns-of-a-data-frame">Efficiently transform multiple columns of a data frame</a></p>
  
  <p>Any ideas in plain beginner language would be very appreciated! If it is possible to nest both operations, it would be even better!</p>