i attempting eliminate leading 0 of 12-hour time value, graphing purposes result must posixlt value. therefore, can-not use regular expressions because leave result character instead of posixlt value.
my time value begins character.
a <- "02:57"
then use strptime
convert character posixlt class. within strptime
, use conversion specification %l, according strptime
help, displays "12-hour clock time single digits preceded blank".
b <- strptime(x = a, tz = "utc", format = "%l")
the variable b posixlt value, , consists of "current date" + "02:57:00" + "local time zone". can live date , time zone, leading 0 of 12-hour time value remains.
how can eliminate leading 0 of 12-hour time value , still retain posixlt class?
i appreciate insight.
i use lubridate
, excellent package working posixlt time objects.
library(lubridate) <- "02:57" b <- hm(a)
yields
> b [1] "2h 57m 0s"
no pesky 0
, sooo other time goodness boot. luck.
Comments
Post a Comment