Skip to contents

This function modifies time values in a dataset to match a new framerate and updates the corresponding metadata. It handles both integer and non-integer time values, ensuring time series start from zero when appropriate.

Usage

set_framerate(data, framerate, old_framerate = 1)

Arguments

data

A data frame or tibble containing the time series data

framerate

The new target framerate to convert to

old_framerate

The original framerate of the data (defaults to 1)

Value

A modified data frame with adjusted time values and updated metadata

Details

The function calculates a scaling factor based on the ratio of old to new framerates. For integer time values, it ensures they start from zero. All time values are then scaled proportionally to maintain relative temporal relationships.

Examples

data <- data.frame(time = 0:10, value = rnorm(11))
result <- set_framerate(data, framerate = 60, old_framerate = 30)