Learn R Programming

reconstructr (version 0.5)

to_seconds: to_seconds

Description

converts POSIX timestamps, or character representations of other timestamp formats, to their numeric value (represented in seconds).

Usage

to_seconds(x, format)

Arguments

x
a vector of POSIXlt/POSIXct timestamps, or character strings representing a different timestamp format.
format
the format the timestamps take - see strptime. Does not need to be set for POSIXlt or POSIXct timestamps.

Value

  • a vector of second-values, one for each timestamp.

Details

to_seconds is designed to enable the rapid conversion of timestamps into their representation as seconds, enabling them to be consumed by sessionise.

See Also

sessionise for making use of the new values.

Examples

Run this code
#Converting non-POSIX timestamps to seconds
data("session_dataset")
session_dataset$timestamp <- to_seconds(x = session_dataset$timestamp, format = "%Y%m%d%H%M%S")

#Converting POSIX timestamps
current_time_in_seconds <- to_seconds(x = Sys.time())

Run the code above in your browser using DataLab