Create a Time-of-Day column in the dataset
Usage
create_Timedata(
dataset,
Datetime.colname = Datetime,
Time.data = Time.data,
output.dataset = TRUE
)
Arguments
- dataset
A light logger dataset. Expects a
dataframe
. If not imported by LightLogR, take care to choose a sensible variable for theDatetime.colname
.- Datetime.colname
column name that contains the datetime. Defaults to
"Datetime"
which is automatically correct for data imported with LightLogR. Expects asymbol
. Needs to be part of thedataset
. Must be of typePOSIXct
.- Time.data
Name of the newly created column. Expects a
symbol
. The default(Time.data
) works well with other functions in LightLogR.- output.dataset
should the output be a
data.frame
(DefaultTRUE
) or a vector withhms
(FALSE
) times? Expects alogical
scalar.
Value
a data.frame
object identical to dataset
but with the added
column of Time-of-Day data, or a vector
with the Time-of-Day-data
Examples
sample.data.environment %>% create_Timedata()
#> # A tibble: 69,120 × 4
#> # Groups: Id [2]
#> Id Datetime MEDI Time.data
#> <fct> <dttm> <dbl> <time>
#> 1 Participant 2023-08-29 00:00:04 0 00'04"
#> 2 Participant 2023-08-29 00:00:14 0 00'14"
#> 3 Participant 2023-08-29 00:00:24 0 00'24"
#> 4 Participant 2023-08-29 00:00:34 0 00'34"
#> 5 Participant 2023-08-29 00:00:44 0 00'44"
#> 6 Participant 2023-08-29 00:00:54 0 00'54"
#> 7 Participant 2023-08-29 00:01:04 0 01'04"
#> 8 Participant 2023-08-29 00:01:14 0 01'14"
#> 9 Participant 2023-08-29 00:01:24 0 01'24"
#> 10 Participant 2023-08-29 00:01:34 0 01'34"
#> # ℹ 69,110 more rows