How to convert to data smaller than 1 second in library(clock) ?

The clock package has been released.

I really appreciate those who were involved in its development.

I always use posix and format when dealing with numbers smaller than 1 second.

In the clock package, there is date_time_build(), which didn't work for me.

Can the clock package make this kind of code even prettier?
Or can I do it by using the hms package?


tiny_day_time <- tibble(year = rep(c(1990),1000),
       month = rep(1,1000),
       day = rep(1,1000),
       hour = rep(5,1000),
       mini = rep(10,1000),
       sec = rep(3,1000),
       milsec = c(1:1000),
       value = sort(rnorm(1000,0,1))
) %>% 
  mutate(milsec = str_pad(milsec,side = c("left"),pad = "0",width = 4)) %>% 
  mutate(dt = str_c(year,"-",month,"-",day," ",hour,":",mini,":",sec,".",milsec),
         dt = format(as.POSIXct(dt), "%Y-%m-%d %H:%M:%OS3")

tiny_day_time %>% 
  theme(axis.text.x = element_text(angle = 90))

Is it possible to create calendar data with clock?
I tried to use date_time_build(), but it didn't work.
For example

date_build(2019, 1:12, 1:31,zone = "America/New_York",ind, invalid = "previous")

date_time_build(2000:2020, 1:12, 1:31, 0:24, 0:60,0:60, zone = "America/New_York", invalid = "previous")

did not work.

Please advise.
thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.