diff --git a/NAMESPACE b/NAMESPACE index eb4dd76..0df1d3f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,8 +17,6 @@ export(edc_data_warn) export(edc_data_warnings) export(edc_db_to_excel) export(edc_example) -export(edc_example_ae) -export(edc_example_mixed) export(edc_example_plot) export(edc_inform_code) export(edc_lookup) diff --git a/man/data_example.Rd b/man/data_example.Rd deleted file mode 100644 index d106785..0000000 --- a/man/data_example.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\name{data_example} -\alias{data_example} -\alias{edc_example_mixed} -\alias{edc_example} -\alias{edc_example_plot} -\alias{edc_example_ae} -\title{Example databases} -\usage{ -edc_example_mixed(N = 100, seed = 42) - -edc_example(N = 50, seed = 42, outdated = FALSE) - -edc_example_ae(N = 50, seed = 42) -} -\arguments{ -\item{N}{the number of patients} - -\item{seed}{the random seed} - -\item{outdated}{simulate times after the data extraction date} -} -\value{ -a list of tables -} -\description{ -List of tables used in EDCimport examples: -\itemize{ -\item \code{edc_example()} can be used as the result of reading functions (such as \code{\link[=read_trialmaster]{read_trialmaster()}} or \code{\link[=read_all_sas]{read_all_sas()}}) and to test \code{\link[=edc_swimmerplot]{edc_swimmerplot()}} -\item \code{edc_example_mixed()} can be used to test \code{\link[=split_mixed_datasets]{split_mixed_datasets()}} -} -} diff --git a/man/edc_data_warn.Rd b/man/edc_data_warn.Rd index 553a0fb..f9e86c5 100644 --- a/man/edc_data_warn.Rd +++ b/man/edc_data_warn.Rd @@ -54,30 +54,30 @@ Use \code{edc_data_warnings()} to generate the table for such a file. library(dplyr) tm = edc_example() load_list(tm) -db0 \%>\% +enrol \%>\% filter(age>70) \%>\% edc_data_warn("Age should not be >70", issue_n=1) -db0 \%>\% +enrol \%>\% filter(age<25) \%>\% edc_data_warn("Age should not be <25", issue_n=2) db1 \%>\% - filter(n()>1, .by=SUBJID) \%>\% + filter(n()>1, .by=subjid) \%>\% edc_data_warn("There are duplicated patients in `db1` ({nrow(.data)} rows)", issue_n=3) -db0 \%>\% +enrol \%>\% filter(age<25) \%>\% edc_data_warn("Age should not be <25", issue_n=NULL) edc_data_warnings() \dontrun{ -db0 \%>\% +enrol \%>\% filter(age<25) \%>\% edc_data_warn("Age should not be <25", csv_path="check/check_age_25.csv") -db0 \%>\% +enrol \%>\% filter(age<25) \%>\% edc_data_stop("Age should *never* be <25") } diff --git a/man/edc_example.Rd b/man/edc_example.Rd new file mode 100644 index 0000000..b92b398 --- /dev/null +++ b/man/edc_example.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\name{edc_example} +\alias{edc_example} +\alias{edc_example_plot} +\title{Example database} +\usage{ +edc_example(N = 50, seed = 42, outdated = FALSE) +} +\arguments{ +\item{N}{the number of patients} + +\item{seed}{the random seed} + +\item{outdated}{whether to simulate times after the data extraction date} +} +\value{ +A list of tables of class \code{edc_database}. +} +\description{ +A list of tables that simulates the extraction of a clinical database. Used in \code{EDCimport} examples and tests. +} diff --git a/man/edc_swimmerplot.Rd b/man/edc_swimmerplot.Rd index b0057c2..8225001 100644 --- a/man/edc_swimmerplot.Rd +++ b/man/edc_swimmerplot.Rd @@ -49,9 +49,9 @@ Join all tables from \code{.lookup$dataset} on \code{id} tm = edc_example_plot() load_list(tm) p = edc_swimmerplot(.lookup, id_lim=c(5,45)) -p2 = edc_swimmerplot(.lookup, origin="db0$date_naissance", time_unit="weeks", +p2 = edc_swimmerplot(.lookup, origin="enrol$date_naissance", time_unit="weeks", exclude=c("DB1$DATE2", "db3$.*")) -p3 = edc_swimmerplot(.lookup, group="db0$group", aes_color="label") +p3 = edc_swimmerplot(.lookup, group="enrol$group", aes_color="label") \dontrun{ #save the plotly plot as HTML to share it save_plotly(p, "edc_swimmerplot.html") diff --git a/man/edc_warn_patient_diffs.Rd b/man/edc_warn_patient_diffs.Rd index ea9832c..7749108 100644 --- a/man/edc_warn_patient_diffs.Rd +++ b/man/edc_warn_patient_diffs.Rd @@ -34,10 +34,10 @@ Compare a subject ID vector to the study's reference subject ID (usually somethi \examples{ tm = edc_example() load_list(tm) -options(edc_subjid_ref=db0$SUBJID) +options(edc_subjid_ref=enrol$subjid) #usually, you set something like: #options(edc_subjid_ref=enrolres$subjid) edc_warn_patient_diffs(db1) -db1 \%>\% dplyr::filter(SUBJID>1) \%>\% edc_warn_patient_diffs() -edc_warn_patient_diffs(c(db1$SUBJID, 99, 999)) +db1 \%>\% dplyr::filter(subjid>1) \%>\% edc_warn_patient_diffs() +edc_warn_patient_diffs(c(db1$subjid, 99, 999)) } diff --git a/man/harmonize_subjid.Rd b/man/harmonize_subjid.Rd index bca2dfd..a64e3f3 100644 --- a/man/harmonize_subjid.Rd +++ b/man/harmonize_subjid.Rd @@ -23,10 +23,10 @@ be performed on the levels. } \examples{ db = edc_example() -db$db0 = head(db$db0, 10) -db$db0$SUBJID \%>\% head() +db$enrol = head(db$enrol, 10) +db$enrol$subjid \%>\% head() db = harmonize_subjid(db) -db$db0$SUBJID \%>\% head() +db$enrol$subjid \%>\% head() db = harmonize_subjid(db, preprocess=function(x) paste0("#", x)) -db$db0$SUBJID \%>\% head() +db$enrol$subjid \%>\% head() } diff --git a/man/select_distinct.Rd b/man/select_distinct.Rd index 2bc7fe5..7e70800 100644 --- a/man/select_distinct.Rd +++ b/man/select_distinct.Rd @@ -19,8 +19,10 @@ Select all columns that has only one level for a given grouping scope. Useful when dealing with mixed datasets containing both long data and repeated short data. } \examples{ -tm = edc_example_ae() -tm$ae \%>\% names -tm$ae \%>\% select_distinct() \%>\% names -tm$ae \%>\% select_distinct(.by=subjid) \%>\% names +db = edc_example() +db$ae \%>\% colnames() +#`crfname` has one level for the whole dataset +db$ae \%>\% select_distinct() \%>\% colnames() +#`n_ae` has one level per patient +db$ae \%>\% select_distinct(.by=subjid) \%>\% colnames() } diff --git a/man/split_mixed_datasets.Rd b/man/split_mixed_datasets.Rd index 2a17d27..11542b6 100644 --- a/man/split_mixed_datasets.Rd +++ b/man/split_mixed_datasets.Rd @@ -16,7 +16,7 @@ split_mixed_datasets( \arguments{ \item{datasets}{a dataframe or a list of dataframes to split. Default to all the datasets from \code{.lookup}.} -\item{id}{the patient identifier, probably "SUBJID". Should be shared by all datasets. Case-insensitive.} +\item{id}{the patient identifier, probably "subjid". Should be shared by all datasets. Case-insensitive.} \item{...}{not used} @@ -45,8 +45,8 @@ print(long_mixed_short) print(long_mixed_long) #alternatively, get the code and only use the datasets you need -split_mixed_datasets(tm, id="SUBJID", output_code=TRUE) +split_mixed_datasets(tm, id="subjid", output_code=TRUE) filename = tempfile("mixed_code", fileext=".R") -split_mixed_datasets(tm, id="SUBJID", output_code=filename) +split_mixed_datasets(tm, id="subjid", output_code=filename) readLines(filename) }