View source: R/sanity_checks.R
edc_data_warn | R Documentation |
When checking your data, filter your dataset to get only problematic rows.
Then, use either:
edc_data_warn()
to generate a standardized warning that can be forwarded to the datamanager
edc_data_warn()
to abort the script if the problem is too serious
Database issues should be traced in a separate file, each with an identifying row number, and the file should be shared with the data-manager.
Use edc_data_warnings()
to generate the table for such a file.
edc_data_warn(
df,
message,
...,
issue_n = "xx",
max_subjid = 5,
csv_path = FALSE,
col_subjid = get_subjid_cols()
)
edc_data_stop(df, message, ..., issue_n, max_subjid, csv_path, col_subjid)
edc_data_warnings()
df |
the filtered dataframe |
message |
the message. Can use cli formats. |
... |
unused |
issue_n |
identifying row number |
max_subjid |
max number of subject ID to show in the message |
csv_path |
a path to save |
col_subjid |
column name for subject ID. Set to |
df
invisibly
library(dplyr)
tm = edc_example()
load_list(tm)
db0 %>%
filter(age>70) %>%
edc_data_warn("Age should not be >70", issue_n=1)
db0 %>%
filter(age<25) %>%
edc_data_warn("Age should not be <25", issue_n=2)
db1 %>%
filter(n()>1, .by=SUBJID) %>%
edc_data_warn("There are duplicated patients in `db1` ({nrow(.data)} rows)", issue_n=3)
db0 %>%
filter(age<25) %>%
edc_data_warn("Age should not be <25", issue_n=NULL)
edc_data_warnings()
## Not run:
db0 %>%
filter(age<25) %>%
edc_data_warn("Age should not be <25", csv_path="check/check_age_25.csv")
db0 %>%
filter(age<25) %>%
edc_data_stop("Age should *never* be <25")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.