Convert periods (hundredth of a second) r
<p>I am trying to convert a vector of the following form:</p>

<pre><code>data$Time[1:10]

[1] 0:00.00 0:00.01 0:00.02 0:00.03 0:00.04 0:00.05 0:00.06 0:00.07 0:00.08 0:00.09
573394 Levels: 0:00.00 0:00.01 0:00.02 0:00.03 0:00.04 0:00.05 0:00.06 0:00.07 0:00.08 0:00.09 0:00.10 0:00.11 0:00.12 0:00.13 0:00.14 ... 9:59.99
</code></pre>

<p>notice that this is a factor form</p>

<pre><code>class(data$Time)

factor
</code></pre>

<p>I've tried the following </p>

<pre><code>hms(data$Time[1:10])

[1] "0S" "1S" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S"
</code></pre>

<p>it sees the 1/100 of a second as a second! same thing for </p>

<pre><code>period_to_seconds(hms(data$Time[1:10]))

[1] 0 1 2 3 4 5 6 7 8 9
</code></pre>

<p>I need to be able to extract the time (with the require accuracy) to be able to subtract and calculate periods. Notice that these files will extend to few hours. So a solution that is good for HH:MM:SS.00 will be appreciated</p>

<p>another approach that only works if you have data that is either H M S or M S solely is the following:</p>

<pre><code>Test &lt;- c('03:5.05', '1:03.05.05')
tmp &lt;- strptime(as.character(Test),"%H:%M:%OS")
tmp
[1] NA NA
tmp &lt;- strptime(as.character(Test),"%M:%OS")
tmp
[1] "2016-04-30 00:03:05.05 CDT" "2016-04-30 00:01:03.05 CDT
</code></pre>

<p>(The hours had to be removed)</p>