Learn R Programming

timetools (version 1.1-2)

subtime: Extract a specific subtime of of POSIXt object or define a subtime object

Description

This function allows to extract a subtime of a time object or to build a subtime object (S3).

Usage

subtime(x, representation, ..., first.day = 0)

## S3 method for class 'default': subtime(x, representation, ..., timezone = "UTC", first.day = 0)

## S3 method for class 'numeric': subtime(x, representation, ..., timezone = "UTC", first.day = 0)

## S3 method for class 'POSIXct': subtime(x, representation, ..., first.day = 0)

## S3 method for class 'POSIXlt': subtime(x, representation, ..., first.day = 0)

## S3 method for class 'TimeInstantDataFrame': subtime(x, representation, ..., first.day = 0)

## S3 method for class 'TimeIntervalDataFrame': subtime(x, representation, cursor = NULL, ..., first.day = 0)

Arguments

x
object to which extract subtime
representation
character string indicating which subtime is to extract ('mday', 'mon', 'wday', 'yday', 'sec', 'min', 'hour').
...
more arguments to or from other methods
timezone
a character string to specify the timezone of subtime
first.day
used only if representation == 'wday'. Interger indicating the first day of the week. 0 -> sunday (the default), 1 -> monday, 2 -> tuesday, etc.
cursor
indicates where the TimeInstant must be taken. If 0, start of each intervals is taken as instant ; if 1 end of each intervals is taken as instant. Any other value will determine a weigthed instant between start and end (

Value

  • a factor which depends on the subtime asked for. See Details.

default

If x is missing, an empty factor with the appropriated levels (according to representation) is returned.

numeric

If x is a numeric, a appropriated subtime factor is returned (in accordance with representation).

Details

subtime extract one of those indicating in the DateTimeClasses documentation.

The result is an ordered factor containing the values corresponding to the given argument x. The levels of the factor are all the available values for that subtime. To know what are those values, see DateTimeClasses documentation.

The factor is given an attributes 'timezone' which correspond of the the timezone of the argument.

See Also

DateTimeClasses, timezone