| ct_to_radian | R Documentation |
This function converts time values into radians, which is often used in circular statistics and time-of-day analyses.
ct_to_radian(data, times, format = "%H:%M:%S", time_zone = "UTC")
data |
A data frame containing a column with time values. Optional. If |
times |
A column name in the |
format |
A string specifying the format of the time values, using the standard POSIX formatting syntax. Default is |
time_zone |
A string specifying the time zone for interpreting the time values. Default is |
This function converts time values into radians based on a 24-hour clock:
A full day (24 hours) corresponds to 2\pi radians.
The fractional time of the day is calculated as:
\text{Fraction of the day} = \frac{\text{hours}}{24} + \frac{\text{minutes}}{1440} + \frac{\text{seconds}}{86400}
For example, for a time of 23 hours, 6 minutes, and 12 seconds:
\text{Fraction of the day} = \frac{23}{24} + \frac{6}{1440} + \frac{12}{86400}
To convert this fraction into radians:
\text{Radians} = \text{Fraction of the day} \times 2\pi
If data is provided, the function returns the input data frame with an additional column named time_radian.
If data is not provided, the function returns a numeric vector of time values converted to radians.
# Convert a standalone vector of time values
times <- c("00:00:00", "06:00:00", "12:00:00", "18:00:00")
ct_to_radian(times = times, format = "%H:%M:%S")
# Convert a column of time values in a data frame
data <- data.frame(times = c("00:00:00", "06:00:00", "12:00:00", "18:00:00"))
ct_to_radian(data = data, times = times, format = "%H:%M:%S")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.