Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201919

How to to show hour term when only minutes and seconds is known in a dataframe?

$
0
0

I have a dataframe, df

str(df)
'data.frame':   1577 obs. of  2 variables:
 $ DATE: Date, format: "2016-02-01""2016-02-01" ...
 $ TIME: Factor w/ 1577 levels "00:01.3","00:01.7",..: 448 449 450 451 453 454 455 456 457 458 …

df$TIME is in "MM:SS" format, where seconds is a fractional seconds with decimal. Since hour term (HH) is missing I want to add hour to the df$TIME so that it has a format of HH:MM:SS. The starting Hour could be 12 such that first observation of df$TIME be like "12:00:01.3"

Finally I want to create a column df$Datetime which could merge both DATE and TIME column.

Please note that the df$TIME do not follow any specific time interval in my case.

Please let me know if its possible


Viewing all articles
Browse latest Browse all 201919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>