Merge event data together
merge_events.Rd
Merge events data set produced by process_events()
with any extra events
that needed to be included by an external source, such as the Actiwatch and
sleep diary.
Usage
merge_events(
data,
add_events,
start_time = NA,
end_time = NA,
off_times = NULL,
good_days = 1:9,
remove_days = FALSE
)
Arguments
- data
A
process.data.events
object produced byprocess_events()
- add_events
A
data.frame
of events to merge withdata
that has the same variable names asdata
.- start_time
A date-time (POSIXct) value that denotes first date and time that should be recorded in merged data set. Default is
NA
to indicate that the merge data set does not need to be subsetted.- end_time
A date-time (POSIXct) value that denotes last date and time that should be recorded in merged data set. Default is
NA
to indicate that the merge data set does not need to be subsetted.- off_times
A
list
containing two objects of equal length denoting the beginning and ending times of when the monitors were removed. For the Pregnancy 24/7 study, thewindows_monitor()
function was used to find these times. Default isNULL
, which indicates that is no monitor off times.- good_days
An integer vector denoting the wear days that have valid data. The default is
1:9
, as for the Pregnancy 24/7 study the wear period last nine days.- remove_days
A logical denoting if merge data set should be subsetted by the
good_days
. Default is FALSE.
Value
A merge.data.events
object, which is a data.frame
with all of the
variables in data
plus the event
variable.
Details
After data
and add_events
have been merged together, all missing
values created by merging the two data set together are filled in by their
appropriate values. For the looping variables, usually, the last value is
carried forwarded. As for the activity variables, it depends on how the
original variable was created as for how the missing values are filled in.
If there are monitor off times, the looping variables are replaced with the
value of 99
to indicate a special type of missing values related to
monitor wear.
There are two more objectives of this function.
Round the
time
variable to the nearest second withlubridate::round_date()
andcreate a new variable called
event
that denotes the event in recorded.