Learn R Programming

activity (version 1.3.4)

gettime: 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")
)

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].

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

See Also

Examples

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

Run the code above in your browser using DataLab