Small helper function to retrieve the (latest) review data from the database
with the given subject id (subject
) and form
.
Arguments
- db_path
Character vector. Needs to be a valid path to a database.
- subject
Character vector with the subject identifier to select from the database.
- form
Character vector with the form identifier to select from the database.
- db_table
Character string. Name of the table to collect. Will only be used if
data
is a character string to a database.- slice_vars
Character vector. Names of the variables that will be used to slice the data frame. Note that the order matters: Slicing will occur for each variable in this vector successively,
- group_vars
Character vector. Variable names of the variables to perform the grouping on.
Examples
local({
temp_path <- withr::local_tempfile(fileext = ".sqlite")
con <- get_db_connection(temp_path)
review_data <- data.frame(
subject_id = "Test_name",
event_name = "Visit 1",
item_group = "Test_group",
form_repeat = 1,
item_name = "Test_item",
edit_date_time = "2023-11-05 01:26:00",
timestamp = "2024-02-05 01:01:01"
) |>
dplyr::as_tibble()
DBI::dbWriteTable(con, "all_review_data", review_data)
db_get_review(temp_path, subject = "Test_name", form = "Test_group")
})
#> # A tibble: 1 × 7
#> subject_id event_name item_group form_repeat item_name edit_date_time
#> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 Test_name Visit 1 Test_group 1 Test_item 2023-11-05 01:26:00
#> # ℹ 1 more variable: timestamp <chr>