diff --git a/inst/WORDLIST b/inst/WORDLIST index 3b01cada..5e73a514 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,11 +1,12 @@ -CGTInformatics CMD Codecov DAGs +DOI GMP Grupp Labelled Lifecycle +MDCs Nonrepeating ORCID OpenSSF @@ -34,7 +35,6 @@ dropdown edu ggeasy ggplot -github gtsummary https httptest @@ -49,6 +49,7 @@ recode recoded recodes skimr +summarise supertbl supertibble supertibble's diff --git a/utility/cli_message_examples_reprex.R b/utility/cli_message_examples_reprex.R new file mode 100644 index 00000000..21234377 --- /dev/null +++ b/utility/cli_message_examples_reprex.R @@ -0,0 +1,157 @@ +#' --- +#' output: reprex::reprex_document +#' --- + +devtools::load_all() + +options(rlang_backtrace_on_error_report = "none") + +# read_redcap + +classic_token <- Sys.getenv("REDCAPTIDIER_CLASSIC_API") +longitudinal_token <- Sys.getenv("REDCAPTIDIER_LONGITUDINAL_API") +redcap_uri <- Sys.getenv("REDCAP_URI") + +## args missing + +# read_redcap() + +# read_redcap(redcap_uri) + +# read_redcap(token = classic_token) + +## redcap_uri + +read_redcap(123, classic_token) + +read_redcap(letters[1:3], classic_token) + +read_redcap("https://www.google.com", classic_token) + +read_redcap("https://www.google.comm", classic_token) + +## token + +read_redcap(redcap_uri, 123) + +read_redcap(redcap_uri, letters[1:3]) + +read_redcap(redcap_uri, "") + +read_redcap(redcap_uri, "CC0CE44238EF65C5DA26A55DD749AF7") # 31 hex characters + +read_redcap(redcap_uri, "CC0CE44238EF65C5DA26A55DD749AF7A") # will be rejected by server + +## unexpected REDCapR error + +try_redcapr(list(success = FALSE, status_code = "", outcome_message = "This is an error message from REDCapR!")) + +## raw_or_label + +read_redcap(redcap_uri, classic_token, raw_or_label = "bad option") + +## forms + +read_redcap(redcap_uri, classic_token, forms = 123) + +## export_survey_fields + +read_redcap(redcap_uri, classic_token, export_survey_fields = 123) + +read_redcap(redcap_uri, classic_token, export_survey_fields = c(TRUE, TRUE)) + +## suppress_redcapr_messages + +read_redcap(redcap_uri, classic_token, suppress_redcapr_messages = 123) + +read_redcap(redcap_uri, classic_token, suppress_redcapr_messages = c(TRUE, TRUE)) + +# data access groups + +read_redcap(redcap_uri, classic_token, export_data_access_groups = TRUE) + +# surveys + +read_redcap(redcap_uri, longitudinal_token, export_survey_fields = TRUE) + +# bind_tibbles + +bind_tibbles(123) + +supertbl <- tibble(redcap_data = list()) +bind_tibbles(supertbl, environment = "abc") + +bind_tibbles(supertbl, tbls = 123) + +# extract_tibbles + +extract_tibbles(letters[1:10]) + +# extract_tibble + +extract_tibble(123, "my_tibble") + +supertbl <- tibble(redcap_data = list()) %>% + as_supertbl() +extract_tibble(supertbl, tbl = 123) + +extract_tibble(supertbl, tbl = letters[1:3]) + +# make_labelled + +make_labelled(123) + +missing_col_supertbl <- tibble(redcap_data = list()) %>% + as_supertbl() +make_labelled(missing_col_supertbl) + +missing_list_col_supertbl <- tibble(redcap_data = list(), redcap_metadata = 123) %>% + as_supertbl() +make_labelled(missing_list_col_supertbl) + +# add_skimr_metadata + +mtcars %>% add_skimr_metadata() + +# write_redcap_xlsx + +withr::with_tempdir({ + dir <- getwd() + filepath <- paste0(dir, "/temp.csv") + REDCapTidieR:::check_file_exists(file = filepath, overwrite = FALSE) +}) + +withr::with_tempdir({ + dir <- getwd() + tempfile <- write.csv(x = mtcars, file = "temp.csv") + filepath <- paste0(dir, "/temp.csv") + REDCapTidieR:::check_file_exists(file = filepath, overwrite = FALSE) +}) + +write_redcap_xlsx(mtcars, file = "temp.xlsx") + +read_redcap(redcap_uri, classic_token) %>% + write_redcap_xlsx(file = "temp.xlsx", add_labelled_column_headers = TRUE) + +withr::with_tempdir({ + dir <- getwd() + filepath <- paste0(dir, "/temp.pdf") + read_redcap(redcap_uri, longitudinal_token) %>% + write_redcap_xlsx(file = filepath) +}) + +withr::with_tempdir({ + dir <- getwd() + filepath <- paste0(dir, "/temp") + read_redcap(redcap_uri, longitudinal_token) %>% + write_redcap_xlsx(file = filepath) +}) + +# Printed supertibble + +read_redcap(Sys.getenv("REDCAP_URI"), Sys.getenv("REDCAPTIDIER_CLASSIC_API")) %>% + suppressWarnings() + +# missing data codes + +read_redcap(redcap_uri, Sys.getenv("REDCAPTIDIER_MDC_API")) diff --git a/utility/cli_message_examples_reprex.md b/utility/cli_message_examples_reprex.md index 61be21eb..0a54bf0a 100644 --- a/utility/cli_message_examples_reprex.md +++ b/utility/cli_message_examples_reprex.md @@ -1,7 +1,6 @@ ``` r devtools::load_all() #> ℹ Loading REDCapTidieR -#> Warning: package 'testthat' was built under R version 4.2.3 options(rlang_backtrace_on_error_report = "none") @@ -256,7 +255,7 @@ withr::with_tempdir({ }) #> Error: #> ✖ File -#> ''/private/var/folders/9c/k1m0bzys7gb1v32g86hfn5sn5k86h1/T/Rtmp677YHR/filec4216b6201a/temp.csv'' +#> ''/private/var/folders/qc/mmjjyjq50530z9r_7mfqcqfhxkkk67/T/RtmpQi1Xne/file52d750f31b3f/temp.csv'' #> already exists. #> ℹ Overwriting files is disabled by default. Set `overwrite = TRUE` to overwrite #> existing file. @@ -297,7 +296,7 @@ withr::with_tempdir({ write_redcap_xlsx(file = filepath) }) #> Warning in write_redcap_xlsx(., file = filepath): ! No extension provided for `file`: -#> '/private/var/folders/9c/k1m0bzys7gb1v32g86hfn5sn5k86h1/T/Rtmp677YHR/filec421a35fb3d/temp' +#> '/private/var/folders/qc/mmjjyjq50530z9r_7mfqcqfhxkkk67/T/RtmpQi1Xne/file52d72e91eb7b/temp' #> ℹ The extension '.xlsx' will be appended to the file name. # Printed supertibble @@ -316,13 +315,13 @@ read_redcap(Sys.getenv("REDCAP_URI"), Sys.getenv("REDCAPTIDIER_CLASSIC_API")) %> #> 7 api_no_access_2 API No Access 2 nonrepea… #> 8 survey Survey nonrepea… #> 9 repeat_survey Repeat Survey repeating -#> # ℹ 4 more variables: data_rows , data_cols , data_size , -#> # data_na_pct +#> # ℹ 5 more variables: data_rows , data_cols , data_size , +#> # data_na_pct , form_complete_pct # missing data codes read_redcap(redcap_uri, Sys.getenv("REDCAPTIDIER_MDC_API")) -#> Warning in read_redcap(redcap_uri, Sys.getenv("REDCAPTIDIER_MDC_API")): ! `yesno` is type 'yesno' but contains non-logical values: UNK +#> Warning in read_redcap(redcap_uri, Sys.getenv("REDCAPTIDIER_MDC_API")): ! `yesno` and `yesno2` are logical but contain non-logical values: UNK #> ℹ These were converted to `NA` resulting in possible data loss #> ℹ Does your REDCap project utilize missing data codes? #> ℹ Silence this warning with `options(redcaptidier.allow.mdc = TRUE)` or set @@ -335,9 +334,9 @@ read_redcap(redcap_uri, Sys.getenv("REDCAPTIDIER_MDC_API")) #> # A REDCapTidieR Supertibble with 1 instruments #> redcap_form_name redcap_form_label redcap_data redcap_metadata structure #> -#> 1 form_1 Form 1 nonrepeat… -#> # ℹ 4 more variables: data_rows , data_cols , data_size , -#> # data_na_pct +#> 1 form_1 Form 1 nonrepeat… +#> # ℹ 5 more variables: data_rows , data_cols , data_size , +#> # data_na_pct , form_complete_pct ``` -Created on 2024-03-21 with [reprex v2.1.0](https://reprex.tidyverse.org) +Created on 2024-03-27 with [reprex v2.1.0](https://reprex.tidyverse.org) diff --git a/vignettes/glossary.Rmd b/vignettes/glossary.Rmd index 7382eaa1..a8ae53ab 100644 --- a/vignettes/glossary.Rmd +++ b/vignettes/glossary.Rmd @@ -227,7 +227,7 @@ The [skimr](https://docs.ropensci.org/skimr/) R package provides summary statist ### Structure {#structure} -The structure of an [instrument](#instrument) can be [repeating](#repeating-instrument), [nonrepeating](#nonrepeating-instrument), or mixed. The [supertibble](#supertibble) shows the instrument's structure in the `structure` column. The structure of a [project](#project) can be [classic](#classic-project), [longitudinal](#longitudinal-project), or longitudinal with [arms](#arm). The structure of an [event](#event) can be [repeating](#repeating-event) or [nonrepeating](#nonrepeating-event). As of REDCapTidier v1.1.0, [mixed structure instruments](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html#mixed-structure-instruments) are supported. The [granularity](#granularity) of a [data tibble](#data-tibble) depends on the structure of all three: the instrument, the project, and the events associated with the instrument. Note: REDCap does not allow repeating instruments inside a repeating event. See also: the section [Longitudinal REDCap projects](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html#longitudinal-redcap-projects) in the [Diving Deeper vignette](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html). ↩︎ +The structure of an [instrument](#instrument) can be [repeating](#repeating-instrument), [nonrepeating](#nonrepeating-instrument), or mixed. The [supertibble](#supertibble) shows the instrument's structure in the `structure` column. The structure of a [project](#project) can be [classic](#classic-project), [longitudinal](#longitudinal-project), or longitudinal with [arms](#arm). The structure of an [event](#event) can be [repeating](#repeating-event) or [nonrepeating](#nonrepeating-event). As of REDCapTidieR v1.1.0, [mixed structure instruments](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html#mixed-structure-instruments) are supported. The [granularity](#granularity) of a [data tibble](#data-tibble) depends on the structure of all three: the instrument, the project, and the events associated with the instrument. Note: REDCap does not allow repeating instruments inside a repeating event. See also: the section [Longitudinal REDCap projects](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html#longitudinal-redcap-projects) in the [Diving Deeper vignette](https://chop-cgtinformatics.github.io/REDCapTidieR/articles/diving_deeper.html). ↩︎ ### Supertibble {#supertibble}