I would like to convert timestamp by milliseconds. Can i still do this with the lubridate package?
library(lubridate)
library(tidyr)
library(dplyr)
df <- data.frame(timestamp = c("1 2018-11-08T07:41:55.921Z",
"2 2018-11-08T07:42:29.842Z",
"3 2018-11-08T07:42:29.845Z",
"4 2018-11-08T07:42:29.845Z",
"5 2018-11-08T07:43:13.957Z"))
df %>%
#note your timestamp has index info, separating that out
separate(timestamp, c('index', 'datetime'), sep = ' ') %>%
# converting the form of "2018-11-08T07:41:55.921Z" to POSIXct date-time objects
# check out `?ymd_hms` docs if you want to force a timezone other than UTC
mutate(time_clean = lubridate::ymd_hms(datetime)) %>%
mutate(
# see https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html
# formating details
date = format(time_clean,format = '%F'),
time = format(time_clean,format = '%T')
)