Hello there,
Consider this simple example
mydf <- tibble(time = c('2018-01-01 15:30:00.000',
'2018-01-01 15:30:00.100',
'2018-01-01 15:30:00.700',
'2018-01-01 15:30:00.800',
'2018-01-01 15:30:00.900',
'2018-01-01 15:30:00.400'),
group = c(1,1,1,2,2,2),
value = c(10,20,30,100,200,300))
# A tibble: 6 x 3
time group value
<chr> <dbl> <dbl>
1 2018-01-01 15:30:00.000 1 10
2 2018-01-01 15:30:00.100 1 20
3 2018-01-01 15:30:00.700 1 30
4 2018-01-01 15:30:00.800 2 100
5 2018-01-01 15:30:00.900 2 200
6 2018-01-01 15:30:00.400 2 300
I would like to parse the datetime correctly. Unfortunately, it seems some rounding is going on even if I try the smarter parse_date_time
.
> mydf %>% mutate(time = lubridate::parse_date_time(time,'%Y-%m-%d %H:%M:%OS3'))
6 parsed with %Y-%Om-%d %H:%M:%OS
# A tibble: 6 x 3
time group value
<dttm> <dbl> <dbl>
1 2018-01-01 15:30:00.000 1 10
2 2018-01-01 15:30:00.099 1 20
3 2018-01-01 15:30:00.700 1 30
4 2018-01-01 15:30:00.799 2 100
5 2018-01-01 15:30:00.900 2 200
6 2018-01-01 15:30:00.400 2 300
Look at these poor milliseconds? What can I do here?
Thanks!!