link_db {mpathsenser} | R Documentation |
Link two sensors OR one sensor and an external data frame using an mpathsenser database
Description
This function is specific to mpathsenser databases. It is a wrapper around link()
but
extracts data in the database for you. It is now soft deprecated as I feel this function's use
is limited in comparison to link()
.
Usage
link_db(
db,
sensor_one,
sensor_two = NULL,
external = NULL,
external_time = "time",
offset_before = 0,
offset_after = 0,
add_before = FALSE,
add_after = FALSE,
participant_id = NULL,
start_date = NULL,
end_date = NULL,
reverse = FALSE,
ignore_large = FALSE
)
Arguments
db |
A database connection to an m-Path Sense database. |
sensor_one |
The name of a primary sensor. See sensors for a list of available sensors. |
sensor_two |
The name of a secondary sensor. See sensors for a list of
available sensors. Cannot be used together with |
external |
Optionally, specify an external data frame. Cannot be used at the same time as a
second sensor. This data frame must have a column called |
external_time |
The name of the column containing the timestamps in |
offset_before |
The time before each measurement in |
offset_after |
The time after each measurement in |
add_before |
Logical value. Do you want to add the last measurement before the start of each interval? |
add_after |
Logical value. Do you want to add the first measurement after the end of each interval? |
participant_id |
A character string identifying a single participant. Use
|
start_date |
Optional search window specifying date where to begin search. Must be convertible to date using as.Date. Use first_date to find the date of the first entry for a participant. |
end_date |
Optional search window specifying date where to end search. Must be convertible to date using as.Date. Use last_date to find the date of the last entry for a participant. |
reverse |
Switch |
ignore_large |
Safety override to prevent long wait times. Set to |
Value
A tibble with the data of sensor_one
with a new column data
with the matched data of
either sensor_two
or external
according to offset_before
or offset_after
. The other way
around when reverse = TRUE
.
See Also
Examples
## Not run:
# Open a database
db <- open_db("path/to/db")
# Link two sensors
link_db(db, "accelerometer", "gyroscope", offset_before = 300, offset_after = 300)
# Link a sensor with an external data frame
link_db(db, "accelerometer",
external = my_external_data,
external_time = "time", offset_before = 300, offset_after = 300
)
## End(Not run)