link_db {mpathsenser}R Documentation

Link two sensors OR one sensor and an external data frame using an mpathsenser database

Description

[Deprecated]

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.

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 time.

external_time

The name of the column containing the timestamps in external.

offset_before

The time before each measurement in x that denotes the period in which y is matched. Must be convertible to a period by lubridate::as.period().

offset_after

The time after each measurement in x that denotes the period in which y is matched. Must be convertible to a period by lubridate::as.period().

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 get_participants to retrieve all participants from the database. Leave empty to get data for all participants.

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 sensor_one with either sensor_two or external? Particularly useful in combination with external.

ignore_large

Safety override to prevent long wait times. Set to TRUE to do this function on lots of data.

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

link()

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)

[Package mpathsenser version 1.2.3 Index]