Skip to content

Commit

Permalink
Prep 1.1.0 for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Hanna authored and Richard Hanna committed Mar 27, 2024
1 parent 28339bb commit 02de4f3
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 13 deletions.
5 changes: 3 additions & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
CGTInformatics
CMD
Codecov
DAGs
DOI
GMP
Grupp
Labelled
Lifecycle
MDCs
Nonrepeating
ORCID
OpenSSF
Expand Down Expand Up @@ -34,7 +35,6 @@ dropdown
edu
ggeasy
ggplot
github
gtsummary
https
httptest
Expand All @@ -49,6 +49,7 @@ recode
recoded
recodes
skimr
summarise
supertbl
supertibble
supertibble's
Expand Down
157 changes: 157 additions & 0 deletions utility/cli_message_examples_reprex.R
Original file line number Diff line number Diff line change
@@ -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"))
19 changes: 9 additions & 10 deletions utility/cli_message_examples_reprex.md
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -316,13 +315,13 @@ read_redcap(Sys.getenv("REDCAP_URI"), Sys.getenv("REDCAPTIDIER_CLASSIC_API")) %>
#> 7 api_no_access_2 API No Access 2 <tibble> <tibble> nonrepea…
#> 8 survey Survey <tibble> <tibble> nonrepea…
#> 9 repeat_survey Repeat Survey <tibble> <tibble> repeating
#> # ℹ 4 more variables: data_rows <int>, data_cols <int>, data_size <lbstr_by>,
#> # data_na_pct <formttbl>
#> # ℹ 5 more variables: data_rows <int>, data_cols <int>, data_size <lbstr_by>,
#> # data_na_pct <formttbl>, form_complete_pct <formttbl>

# 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
Expand All @@ -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
#> <chr> <chr> <list> <list> <chr>
#> 1 form_1 Form 1 <tibble [3 × 8]> <tibble> nonrepeat…
#> # ℹ 4 more variables: data_rows <int>, data_cols <int>, data_size <lbstr_by>,
#> # data_na_pct <formttbl>
#> 1 form_1 Form 1 <tibble [3 × 9]> <tibble> nonrepeat…
#> # ℹ 5 more variables: data_rows <int>, data_cols <int>, data_size <lbstr_by>,
#> # data_na_pct <formttbl>, form_complete_pct <formttbl>
```

<sup>Created on 2024-03-21 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>
<sup>Created on 2024-03-27 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>
2 changes: 1 addition & 1 deletion vignettes/glossary.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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). <a onclick="history.back()">↩︎</a>
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). <a onclick="history.back()">↩︎</a>

### Supertibble {#supertibble}

Expand Down

0 comments on commit 02de4f3

Please sign in to comment.