r - Extract time from timestamp? -


essentially, want hour, minute, , seconds column of timestamps have in r, because want view how different data points occur throughout different times of day , day , date irrelevant.

however, how timestamps structured in dataset: 2008-08-07t17:07:36z

and i'm unsure how time timestamp.

thank can provide , please let me know if can provide more information!

we can use strptime convert datetime class , format extract hour:min:sec.

dtime <- strptime(str1, "%y-%m-%dt%h:%m:%sz") format(dtime, "%h:%m:%s") #[1] "17:07:36" 

if op wants have hour, min, sec separate columns

read.table(text=format(dtime, "%h:%m:%s"), sep=":", header=false) #  v1 v2 v3 #1 17  7 36 

another option using lubridate

library(lubridate) format(ymd_hms(str1), "%h:%m:%s") #[1] "17:07:36" 

data

str1 <- "2008-08-07t17:07:36z" 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -