| Title: | Processing of 'CARWatch' Sampling Logs and Saliva Data |
|---|---|
| Description: | Import and reconstruct saliva-sampling studies recorded by the 'CARWatch' application. Registration metadata and raw barcode events are converted into auditable study days and scheduled sample positions using a two-pass issue-review workflow. Functions assess sampling-time compliance, merge laboratory saliva measurements, calculate response features, and create quality-control visualizations. The application is described by Richer et al. (2023) <doi:10.1016/j.psyneuen.2023.106073>. |
| Authors: | Robert Richer [aut, cre] (ORCID: <https://orcid.org/0000-0003-0272-5403>) |
| Maintainer: | Robert Richer <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-09-17 13:46:38 UTC |
| Source: | https://github.com/cran/carwatch |
Extract the explicit sample-level table
as_sample_events(data)as_sample_events(data)
data |
Complete canonical Study Results. |
A tibble with one row per participant, day, and scheduled sample.
Extract the explicit day-level table
as_study_days(data)as_study_days(data)
data |
Complete canonical Study Results. |
A tibble with one row per participant and canonical day.
Compute area under the curve with respect to ground and increase
auc( data, saliva_type = "cortisol", remove_s0 = FALSE, compute_auc_post = FALSE, sample_times = NULL )auc( data, saliva_type = "cortisol", remove_s0 = FALSE, compute_auc_post = FALSE, sample_times = NULL )
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
remove_s0 |
Whether to remove baseline sample S0. |
compute_auc_post |
Whether to add post-baseline AUCi. |
sample_times |
Sampling-time vector or column name. |
Group-level AUC values.
Compute the standard CARWatch saliva response feature set
compute_features( data, saliva_type = "cortisol", group_levels = NULL, sample_level = NULL, sample_times = NULL, slope_pairs = NULL, remove_s0 = FALSE )compute_features( data, saliva_type = "cortisol", group_levels = NULL, sample_level = NULL, sample_times = NULL, slope_pairs = NULL, remove_s0 = FALSE )
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
group_levels |
Grouping column names. |
sample_level |
Sample-position column name. |
sample_times |
Sampling-time vector or column name. |
slope_pairs |
Sample pairs for slopes. |
remove_s0 |
Whether to remove baseline sample S0. |
Group-level response features.
curve <- tibble::tibble( participant = "P01", sample = paste0("S", 1:4), time_min = c(0, 30, 45, 60), cortisol = c(5, 9, 8, 7) ) compute_features( curve, group_levels = "participant", sample_level = "sample", sample_times = "time_min" )curve <- tibble::tibble( participant = "P01", sample = paste0("S", 1:4), time_min = c(0, 30, 45, 60), cortisol = c(5, 9, 8, 7) ) compute_features( curve, group_levels = "participant", sample_level = "sample", sample_times = "time_min" )
Compute CARWatch saliva features using sample position and actual time
compute_features_from_carwatch( data, saliva_type = "cortisol", slope_pairs = NULL, group_levels = NULL )compute_features_from_carwatch( data, saliva_type = "cortisol", slope_pairs = NULL, group_levels = NULL )
data |
Canonical results or sample events. |
saliva_type |
Measurement column name. |
slope_pairs |
Sample pairs for slopes. |
group_levels |
Additional R column names that identify separate curves. |
Per participant-day response features.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) compute_features_from_carwatch(merged)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) compute_features_from_carwatch(merged)
The table is shown on the left and issue-specific decision controls on the
right. The report remains immutable until the selected row passes the same
validation used by convert_raw_logs(). When raw_logs is supplied,
Refresh remaining issues applies the cumulative decisions to the original
events with errors = "warn" and replaces the visible table with unresolved
issues from the new conversion. A diary-backed decision that cannot be
applied is reset to Leave unresolved while successfully applied decisions
are hidden. Resolved upstream decisions remain in the history returned by
Done. Mouse and arrow-key row selection both update the decision controls.
conversion_report_editor( report, launch = interactive(), host = "127.0.0.1", port = NULL, raw_logs = NULL, protocol_manifest = NULL, sampling_schedule = NULL, manual_diary = NULL, check_compliance = TRUE, compliance_checker = new_sampling_compliance_checker() )conversion_report_editor( report, launch = interactive(), host = "127.0.0.1", port = NULL, raw_logs = NULL, protocol_manifest = NULL, sampling_schedule = NULL, manual_diary = NULL, check_compliance = TRUE, compliance_checker = new_sampling_compliance_checker() )
report |
A conversion report list or its editable issue table. |
launch |
Run the Shiny gadget immediately. Set |
host |
Host passed to |
port |
Optional port passed to |
raw_logs |
Optional immutable raw events. Required to enable refreshing the conversion after decisions change. |
protocol_manifest, sampling_schedule, manual_diary, check_compliance, compliance_checker
|
Conversion settings forwarded unchanged by |
A validated issue tibble, NULL after cancellation, or a Shiny app
object when launch = FALSE.
The first pass only reports issues. Decisions passed through issue_decisions
are the only allowed route for corrections; raw event rows are never changed.
convert_raw_logs( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error"), create_report = FALSE, issue_decisions = NULL, sampling_schedule = NULL, manual_diary = NULL, check_compliance = TRUE, compliance_checker = new_sampling_compliance_checker() )convert_raw_logs( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error"), create_report = FALSE, issue_decisions = NULL, sampling_schedule = NULL, manual_diary = NULL, check_compliance = TRUE, compliance_checker = new_sampling_compliance_checker() )
raw_logs |
Immutable events returned by |
protocol_manifest |
Optional ordered registration configuration. |
errors |
Unresolved-issue handling: "raise", "warn", or legacy "error". |
create_report |
Return a list containing results and the issue report. |
issue_decisions |
A prior editable issue report with decisions. |
sampling_schedule |
Optional fallback schedule for |
manual_diary |
Optional normalized manual diary. |
check_compliance |
Whether to calculate timing compliance. |
compliance_checker |
Timing tolerance configuration. |
Canonical results, or a results/report list.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") raw_logs <- read_raw_logs(file.path(fixture, "raw", "VP01")) converted <- convert_raw_logs(raw_logs, errors = "warn", create_report = TRUE) converted$report$issues as_sample_events(converted$results)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") raw_logs <- read_raw_logs(file.path(fixture, "raw", "VP01")) converted <- convert_raw_logs(raw_logs, errors = "warn", create_report = TRUE) converted$report$issues as_sample_events(converted$results)
Remove non-compliant observations
drop_non_compliant_samples( data, drop_entire_day = TRUE, drop_unassessed = FALSE )drop_non_compliant_samples( data, drop_entire_day = TRUE, drop_unassessed = FALSE )
data |
Canonical results or sample events. |
drop_entire_day |
Whether one failed sample removes its day. |
drop_unassessed |
Whether missing assessments are removed. |
Filtered data preserving canonical results when supplied.
Extract the registration-aware protocol schedule
extract_registration_schedule( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error") )extract_registration_schedule( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error") )
raw_logs |
Immutable events returned by |
protocol_manifest |
Optional ordered registration configuration. |
errors |
Unresolved-issue handling: "raise", "warn", or legacy "error". |
A tibble with registration-aware sample positions.
Identify non-compliant samples
find_non_compliant_samples(data)find_non_compliant_samples(data)
data |
Canonical results or sample events. |
Rows with failed compliance.
Identify tube and day mismatches
find_sampling_anomalies(data)find_sampling_anomalies(data)
data |
Canonical results or sample events. |
Rows with sampling anomalies.
Generated anomalies are represented by ordinary raw-log omissions and a matching manual diary/decision report. The source events themselves are never patched. Study Manager snake-case, camelCase, and QR aliases are accepted, including multiple registration blocks and opaque saliva IDs.
generate_synthetic_study_data( output_dir, study_config = NULL, n_participants = NULL, non_compliant_sample_ratio = 0.1, missing_awakening_time_ratio = 0.01, missing_sampling_time_ratio = 0.02, random_state = 42L, create_cortisol_data = FALSE, overwrite = FALSE, validate = TRUE )generate_synthetic_study_data( output_dir, study_config = NULL, n_participants = NULL, non_compliant_sample_ratio = 0.1, missing_awakening_time_ratio = 0.01, missing_sampling_time_ratio = 0.02, random_state = 42L, create_cortisol_data = FALSE, overwrite = FALSE, validate = TRUE )
output_dir |
Target directory. |
study_config |
Study Manager-style list, decoded |
n_participants |
Number of generated participants. When |
non_compliant_sample_ratio |
Proportion of expected samples with timing deliberately outside the default compliance tolerance. Relative and fixed clock-time samples use their respective tolerance-aware deviation ranges. |
missing_awakening_time_ratio |
Proportion of participant-days with a missing awakening event and first sample. |
missing_sampling_time_ratio |
Total proportion of expected scans omitted. |
random_state |
Integer seed, or |
create_cortisol_data |
Whether to create position-indexed |
overwrite |
Whether an existing target directory may be replaced. |
validate |
Run advisory and submitted-decision conversion after writing. |
The normalized output directory path.
output <- tempfile("carwatch-study-") generate_synthetic_study_data( output, study_config = list(study_days = 1, saliva_distances = c(0, 30)), n_participants = 1, non_compliant_sample_ratio = 0, missing_awakening_time_ratio = 0, missing_sampling_time_ratio = 0, validate = FALSE ) unlink(output, recursive = TRUE)output <- tempfile("carwatch-study-") generate_synthetic_study_data( output, study_config = list(study_days = 1, saliva_distances = c(0, 30)), n_participants = 1, non_compliant_sample_ratio = 0, missing_awakening_time_ratio = 0, missing_sampling_time_ratio = 0, validate = FALSE ) unlink(output, recursive = TRUE)
Return the initial value in each saliva curve
initial_value(data, saliva_type = "cortisol", remove_s0 = FALSE)initial_value(data, saliva_type = "cortisol", remove_s0 = FALSE)
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
remove_s0 |
Whether to remove baseline sample S0. |
Group-level initial values.
This R-native replacement for the Python notebook widget uses Shiny. The
app owns participant/day selectors and redraws plot_sampling_timeline().
interactive_sampling_timeline( data, show_expected = TRUE, launch = interactive(), host = "127.0.0.1", port = NULL )interactive_sampling_timeline( data, show_expected = TRUE, launch = interactive(), host = "127.0.0.1", port = NULL )
data |
Complete canonical results or a sample-event tibble. |
show_expected |
Whether registered target times are drawn. |
launch |
Run the app immediately. Set |
host |
Host passed to |
port |
Optional port passed to |
A Shiny app object when launch = FALSE; otherwise the result of
shiny::runApp().
Compute maximum increase from the initial sample
max_increase( data, saliva_type = "cortisol", remove_s0 = FALSE, percent = FALSE )max_increase( data, saliva_type = "cortisol", remove_s0 = FALSE, percent = FALSE )
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
remove_s0 |
Whether to remove baseline sample S0. |
percent |
Whether to return the percentage increase. |
Group-level maximum increase.
Compute the maximum measured value in each saliva curve
max_value(data, saliva_type = "cortisol", remove_s0 = FALSE)max_value(data, saliva_type = "cortisol", remove_s0 = FALSE)
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
remove_s0 |
Whether to remove baseline sample S0. |
Group-level maximum values.
Compute mean and standard error by sample
mean_se(data, saliva_type = "cortisol", group_cols = NULL, remove_s0 = FALSE)mean_se(data, saliva_type = "cortisol", group_cols = NULL, remove_s0 = FALSE)
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
group_cols |
Grouping columns. |
remove_s0 |
Whether to remove baseline sample S0. |
Mean and standard error by sample.
Raw tube identifiers remain opaque. With match_on = "sample" values are matched to the recorded tube (falling back to the scheduled tube); with match_on = "position" they are matched to registration-aware positions.
merge_saliva( study_results, saliva, correct_swaps = TRUE, match_on = c("sample", "position", "physical_id"), missing_carwatch_data = c("ignore", "raise"), metadata_cols = NULL )merge_saliva( study_results, saliva, correct_swaps = TRUE, match_on = c("sample", "position", "physical_id"), missing_carwatch_data = c("ignore", "raise"), metadata_cols = NULL )
study_results |
Complete canonical results. |
saliva |
Long laboratory tibble. |
correct_swaps |
Match physical tubes to their recorded position. |
match_on |
"sample"/"physical_id" or "position". |
missing_carwatch_data |
Whether unmatched laboratory rows are ignored or rejected. |
metadata_cols |
Optional laboratory columns to retain as metadata rather than numeric measurements. When omitted, non-numeric non-key columns are treated as metadata. This is the R equivalent of additional pandas index levels. Constant participant-day values are stored at the canonical day level; values varying within any day stay sample-level everywhere. |
Complete canonical results with laboratory and merge-provenance fields.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) as_sample_events(merged)[c("participant", "sample", "cortisol")]fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) as_sample_events(merged)[c("participant", "sample", "cortisol")]
A carwatch_results object is an R-native representation of the Python
package's participant-indexed, three-level wide table. Internally it is a
tibble with a participant column and safe column names. The column_spec
attribute maps every value column reversibly to day, sample, and
variable; opaque sample IDs are never encoded into the internal names.
new_carwatch_results(data, column_spec, display_only = FALSE)new_carwatch_results(data, column_spec, display_only = FALSE)
data |
Tibble containing |
column_spec |
Tibble with |
display_only |
Whether required provenance has intentionally been removed. |
A carwatch_results object: a tibble with one row per participant,
a column_spec attribute mapping value columns to day, sample, and
variable, and a carwatch_display_only attribute.
Configure CARWatch sampling-compliance tolerances
new_sampling_compliance_checker( awakening_delay_tolerance_min = 5, sampling_delay_tolerance_min = 5, absolute_time_tolerance_min = 15, check_absolute_times = TRUE )new_sampling_compliance_checker( awakening_delay_tolerance_min = 5, sampling_delay_tolerance_min = 5, absolute_time_tolerance_min = 15, check_absolute_times = TRUE )
awakening_delay_tolerance_min |
Tolerance for the first relative sample. |
sampling_delay_tolerance_min |
Tolerance for later relative samples. |
absolute_time_tolerance_min |
Tolerance for fixed-time samples. |
check_absolute_times |
Whether fixed-time samples are evaluated. |
A carwatch_compliance_checker list containing the configured
tolerance values and the check_absolute_times flag.
Plot cohort sampling compliance
plot_compliance_overview( data, by = "sample_position", view = c("proportion", "heatmap") )plot_compliance_overview( data, by = "sample_position", view = c("proportion", "heatmap") )
data |
Canonical results or sample events. |
by |
Summary grouping variable. |
view |
Plot form. |
A ggplot object.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_compliance_overview(results)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_compliance_overview(results)
Actual time_min values define the horizontal axis. Faint lines show
participant-day curves. Thick lines connect group means calculated
separately at each registered sample_position; shaded ribbons show BCa
bootstrap confidence intervals when at least two measurements contribute.
plot_saliva_curve( data, value = "cortisol", participant = NULL, day = NULL, group_by = NULL, ci = 95, n_boot = 1000, seed = 0, show_individual = TRUE )plot_saliva_curve( data, value = "cortisol", participant = NULL, day = NULL, group_by = NULL, ci = 95, n_boot = 1000, seed = 0, show_individual = TRUE )
data |
Canonical results or sample events. |
value |
Non-empty name of the saliva measurement column. |
participant |
Optional exact participant filter. |
day |
Optional exact canonical-day filter. |
group_by |
Optional character vector defining separate aggregate curves. |
ci |
Bootstrap confidence level between 0 and 100, or |
n_boot |
Positive number of bootstrap resamples. |
seed |
Integer random seed, or |
show_individual |
Whether individual participant-day curves are drawn. |
A ggplot object.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) plot_saliva_curve(merged, ci = NULL)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) saliva <- read_saliva(file.path(fixture, "saliva.csv")) merged <- merge_saliva(results, saliva) plot_saliva_curve(merged, ci = NULL)
Actual sampling events are coloured by compliance and shaped by timestamp
provenance. When show_expected = TRUE, hollow grey circles show the static
protocol targets, hollow blue diamonds show targets updated from preceding
recorded relative samples, and arrows show the signed deviation from the
app-updated target. Missing relative scans break the adaptive target chain.
Missing events and scheduled/recorded sample mismatches remain visible.
plot_sampling_timeline(data, participant, day, show_expected = TRUE)plot_sampling_timeline(data, participant, day, show_expected = TRUE)
data |
Canonical results or sample events. |
participant |
Participant identifier. |
day |
Canonical day identifier. |
show_expected |
Whether expected sampling times are shown. |
A ggplot object.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_sampling_timeline(results, participant = "VP01", day = "D1")fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_sampling_timeline(results, participant = "VP01", day = "D1")
Negative values indicate early collection and positive values late collection. Boxes summarize each group while jittered points retain every recorded observation.
plot_timing_deviation(data, by = "sample_position")plot_timing_deviation(data, by = "sample_position")
data |
Canonical results or sample events. |
by |
Grouping variable. Defaults to |
A ggplot object.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_timing_deviation(results)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) plot_timing_deviation(results)
Read a conversion-issue report CSV
read_conversion_report(path)read_conversion_report(path)
path |
CSV path. |
A validated editable issue tibble.
Read a manual measurement diary
read_manual_diary(path)read_manual_diary(path)
path |
Wide CSV diary. |
A tibble keyed by participant and canonical day.
Read CARWatch raw log files
read_raw_logs( path, tz = "Europe/Berlin", errors = c("raise", "warn", "ignore", "error") )read_raw_logs( path, tz = "Europe/Berlin", errors = c("raise", "warn", "ignore", "error") )
path |
CSV file, ZIP archive, directory, or vector of paths. |
tz |
IANA timezone for Unix timestamps. |
errors |
Invalid-payload handling: |
A tibble of immutable raw events.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") raw_logs <- read_raw_logs(file.path(fixture, "raw", "VP01")) head(raw_logs)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") raw_logs <- read_raw_logs(file.path(fixture, "raw", "VP01")) head(raw_logs)
Read raw logs from one explicitly mapped folder per participant
read_raw_logs_from_participant_dirs( participant_dirs, tz = "Europe/Berlin", errors = c("raise", "warn", "ignore", "error"), create_report = FALSE )read_raw_logs_from_participant_dirs( participant_dirs, tz = "Europe/Berlin", errors = c("raise", "warn", "ignore", "error"), create_report = FALSE )
participant_dirs |
Named paths, one folder per participant. |
tz |
IANA study timezone. |
errors |
Invalid-payload handling. |
create_report |
Whether to return the source audit. |
Raw events, or a raw-events/source-audit list.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") folders <- c(VP01 = file.path(fixture, "raw", "VP01")) imported <- read_raw_logs_from_participant_dirs(folders, create_report = TRUE) head(imported$source_audit)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") folders <- c(VP01 = file.path(fixture, "raw", "VP01")) imported <- read_raw_logs_from_participant_dirs(folders, create_report = TRUE) head(imported$source_audit)
Read a BioPsyKit-style saliva CSV
read_saliva(path, saliva_type = "cortisol")read_saliva(path, saliva_type = "cortisol")
path |
CSV containing exactly |
saliva_type |
Biomarker column name. |
A tibble.
Read a flat CARWatch Study Manager export
read_study_manager_export(path, tz = "Europe/Berlin")read_study_manager_export(path, tz = "Europe/Berlin")
path |
Path to a Study Manager export. |
tz |
IANA study timezone. |
Complete carwatch_results.
Reads the three-header CSV produced by either carwatch-python or
write_study_results(). The returned object preserves opaque identifiers,
time zones, and column placement.
read_study_results(path, tz = "Europe/Berlin", simple = FALSE)read_study_results(path, tz = "Europe/Berlin", simple = FALSE)
path |
Path to a three-header Study Results CSV. |
tz |
IANA study timezone. |
simple |
Return a display-only subset. |
A carwatch_results object.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) as_study_days(results)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) as_study_days(results)
Convert wide saliva features to an analysis-friendly long table
saliva_feature_wide_to_long(data, saliva_type = "cortisol")saliva_feature_wide_to_long(data, saliva_type = "cortisol")
data |
Feature table returned by |
saliva_type |
Biomarker prefix to select. |
A tibble with saliva_feature and biomarker value columns.
Convert clock-time sample columns to minutes from the first sample
sample_times_datetime_to_minute(data, sample_cols = NULL)sample_times_datetime_to_minute(data, sample_cols = NULL)
data |
A data frame whose selected columns contain |
sample_cols |
Sample-time columns; all columns are used by default. |
A tibble of numeric minute offsets.
Compute the slope between two saliva samples
slope( data, sample_labels = NULL, sample_idx = NULL, saliva_type = "cortisol", sample_times = NULL )slope( data, sample_labels = NULL, sample_idx = NULL, saliva_type = "cortisol", sample_times = NULL )
data |
Saliva data or canonical results. |
sample_labels |
Two sample labels. |
sample_idx |
Two one-based sample indices. |
saliva_type |
Measurement column name(s). |
sample_times |
Sampling-time vector or column name. |
Group-level slope values.
Summarize descriptive saliva features
standard_features( data, saliva_type = "cortisol", group_cols = NULL, keep_index = TRUE )standard_features( data, saliva_type = "cortisol", group_cols = NULL, keep_index = TRUE )
data |
Saliva data or canonical results. |
saliva_type |
Measurement column name(s). |
group_cols |
Grouping columns. |
keep_index |
Retained for API compatibility. |
Descriptive saliva features.
Summarize sampling compliance
summarize_compliance(data, group_by = "sample_position")summarize_compliance(data, group_by = "sample_position")
data |
Canonical results or a sample-event tibble. |
group_by |
Grouping column(s), or |
A tibble with assessed, compliant, non-compliant, and unassessed counts.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) summarize_compliance(results)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) summarize_compliance(results)
Summarize the reconstructed study protocol
summarize_protocol( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error") )summarize_protocol( raw_logs, protocol_manifest = NULL, errors = c("raise", "warn", "error") )
raw_logs |
Immutable events returned by |
protocol_manifest |
Optional ordered registration configuration. |
errors |
Unresolved-issue handling. |
A registration-level tibble.
Compactly summarize a source audit
summarize_source_audit(source_audit)summarize_source_audit(source_audit)
source_audit |
Source audit returned by |
A one-column tibble with three values named raw_log_import: the
number of selected logs, the total raw events in selected logs, and the
number of distinct participants, in that order.
Write an editable conversion report
write_conversion_report(report, path)write_conversion_report(report, path)
report |
A conversion report list or its issue table. |
path |
Destination CSV path. |
path, invisibly.
Write canonical CARWatch Study Results
write_study_results(data, path)write_study_results(data, path)
data |
Complete |
path |
Destination CSV path. |
path, invisibly. The function writes the canonical Study Results
CSV and returns its absolute path.
fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) output <- tempfile(fileext = ".csv") write_study_results(results, output) restored <- read_study_results(output)fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch") results <- read_study_results(file.path(fixture, "results.csv")) output <- tempfile(fileext = ".csv") write_study_results(results, output) restored <- read_study_results(output)