circular_time_mean_sd: Circular mean, SD, and center adjustment for clock time

View source: R/circular_time_mean_sd.R

circular_time_mean_sdR Documentation

Circular mean, SD, and center adjustment for clock time

Description

A function for calculating the circular average timing and circular standard deviation of time variables measured on a 24-hour clock. Times larger than 24 hours are wrapped onto the 24-hour scale using modulo arithmetic. The function also returns signed deviations from a specified center, or from the circular mean if center is not provided.

Usage

circular_time_mean_sd(times, unit_to_minute = 60, out = c("mean", "sd"))

Arguments

times

numeric A vector of clock times or elapsed times. Values larger than 24 hours are converted to clock time using x %/% 24. Missing values are ignored.

unit_to_minute

numeric The ratio of the unit of time and minute. For example, the input unit is hour, the unit2minute = 60.

out

character Specify get the mean or sd of the time variables. Default=c("mean","sd") when both mean and sd are calculated.

Details

The circular mean is computed by minimizing the total squared circular distance on a 24-hour clock. The signed difference is defined on (-12, 12] hours, so the shortest clockwise or counterclockwise distance is used.

Value

A list with:

mean

Circular mean of the input times, in hours.

sd

Circular standard deviation of the input times, in hours.

Examples

circular_time_mean_sd(c(1, 2, 3, 21, 20, 23))
circular_time_mean_sd(c(23, 1, 2) )


mMARCH.AC documentation built on June 18, 2026, 5:07 p.m.