I am extracting a time variable from the output of an API request and the output format is as follows.
> a
[1] "2019-09-06T09:03:14.938Z"
The first objective is to derive the difference with Sys.time()
> b<- Sys.time()
> b
[1] "2019-09-06 08:57:08 UTC"
I am having issues to run a basic c = a-b
> c<-a-b
Error in `-.POSIXt`(a, b) : can only subtract from "POSIXt" objects
When trying to convert a
into a POSIXT
object, I get the following error:
> c<-as.POSIXct.Date(a)
Error in unclass(x) * 86400 : non-numeric argument to binary operator
The second objective would be to make the code wait until the time difference is possitive or zero. Maybe somethimg using sys.sleep
?