downsample_time_series: Downsample a timeseries with a datetime object

View source: R/downsample_time_series.R

downsample_time_seriesR Documentation

Downsample a timeseries with a datetime object

Description

This function will resample time series data ( downsample) to the nearest minute, half-hour, hour, or day. It allow to summarise the measurement values using mean, median, or sum.

Usage

downsample_time_series(data = NULL, datetime_column = "datetime",amount = 30,
       units = c("minute", "hour", "day", "week"), method = c("mean", "sum", "median"))

Arguments

data

data frame or tibble with 2 columns. One column must be a POSIXct object.

datetime_column

column in data that has the datetime

amount

the amount of units to downsample for

units

a character object like:"hour", "minute", "day", "week". Default is "minute"

method

methods by which to summarise the measurement values in the timeseries: "mean", "sum", "median". Default is "mean".

Value

A data.frame with 2 columns: downsampled_data: summarise measurement values floored_dates: downsampled POSIXct object

Examples

df_downsampled <- downsample_time_series(data = raw_data,
datetime_column = "datetime", amount = 30, units = "hour", method = "sum")


edpclau/circadian-dynamics documentation built on Aug. 25, 2023, 12:18 p.m.