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
.- 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]
#> Datetime MEDI Id Time.data
#> <dttm> <dbl> <chr> <time>
#> 1 2023-08-15 00:00:01 0 Participant 00'01"
#> 2 2023-08-15 00:00:11 0 Participant 00'11"
#> 3 2023-08-15 00:00:21 0 Participant 00'21"
#> 4 2023-08-15 00:00:31 0 Participant 00'31"
#> 5 2023-08-15 00:00:41 0 Participant 00'41"
#> 6 2023-08-15 00:00:51 0 Participant 00'51"
#> 7 2023-08-15 00:01:01 0 Participant 01'01"
#> 8 2023-08-15 00:01:11 0 Participant 01'11"
#> 9 2023-08-15 00:01:21 0 Participant 01'21"
#> 10 2023-08-15 00:01:31 0 Participant 01'31"
#> # ℹ 69,110 more rows