TrajConvertTime: Converts a delimited time string to a numeric value

View source: R/convenience.R

TrajConvertTimeR Documentation

Converts a delimited time string to a numeric value

Description

Time values may be imported in a format which is not immediately usable by 'trajr'. This function converts times that are specified as a number of delimited fields to a single numeric value. The default parameter values handle a value with 4 colon-separated values, which are hours, minutes, seconds and milliseconds, eg: "0:01:04:108" represents 1 minute, 4 seconds and 108 milliseconds, or 64.108 seconds.

Usage

TrajConvertTime(time, sep = ":", factors = c(60 * 60, 60, 1, 0.001))

Arguments

time

A character string containing the time value to be converted.

sep

Field separator.

factors

Vector of numeric factors to be applied to each field, in the order they occur within 'time'. The default assumes 4 fields containing numeric hours, minutes, seconds and milliseconds.

Details

Note that the base R strptime can be used to convert time values in more complex date/time formats, but it does not handle millisecond fields.

Value

'time' converted to a numeric value.

See Also

strptime

Examples

time <- c("0:00:00:029", "0:01:00:216", "0:02:01:062", "1:00:02:195", "1:06:03:949", "1:42:04:087")
seconds <- TrajConvertTime(time)


JimMcL/trajr documentation built on July 23, 2024, 2:06 a.m.