Learn R Programming

scanstatistics (version 0.1.0)

add_duration: Add a column duration to a data.table with column time.

Description

Adds a column duration to a data.table with column time, the most recent time given a duration of 1, the second most recent time given a duration of 2, and so on. This function modifies the input table.

Usage

add_duration(d, keys = NULL, silent = TRUE)

Arguments

d

A data.table containing at least a column time, which is sortable. For example, could be POSIXct dates.

keys

A character vector for the columns you wish the output table to be keyed by.

silent

Should the table be modified and this function return nothing (silent = TRUE), or should the function return the modified table (silent = FALSE).

Value

The input data.table, with a column duration added.