gettime: Convert time of day data to numeric

View source: R/activity_code.r

gettimeR Documentation

Convert time of day data to numeric

Description

Accepts data of class POSIXct, POSIXlt or character and returns the time of day element as numeric (any date element is ignored).

Usage

gettime(
  x,
  scale = c("radian", "hour", "proportion"),
  ...,
  tryFormats = c("%Y-%m-%d %H:%M:%OS", "%Y/%m/%d %H:%M:%OS",
    "%Y:%m:%d %H:%M:%OS", "%Y-%m-%d %H:%M", "%Y/%m/%d %H:%M",
    "%Y:%m:%d %H:%M", "%Y-%m-%d", "%Y/%m/%d", "%Y:%m:%d")
)

Arguments

x

A vector of POSIXct, POSIXlt or character format time data to convert.

scale

The scale on which to return times (see Value for options).

...

arguments passed to as.POSIXlt

tryFormats

formats to try when converting date from character, passed to as.POSIXlt

Value

A vector of numeric times of day in units defined by the scale argument: radian, on the range [0, 2*pi]; hours, on the range [0, 24]; proportion, on the range [0, 1].

See Also

strptime

Examples

data(BCItime)
rtime <- gettime(BCItime$date)
htime <- gettime(BCItime$date, "hour")
ptime <- gettime(BCItime$date, "proportion")
summary(rtime)
summary(htime)
summary(ptime)

activity documentation built on Sept. 27, 2023, 9:08 a.m.

Related to gettime in activity...