diff --git a/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md b/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md index 2fb86348..3908a715 100644 --- a/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md +++ b/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md @@ -7,19 +7,15 @@ assignees: '' --- -**Describe the behavior** -Please provide a clear and concise description of the scenario and the behavior. *Be careful not to include tokens, PHI (protected health information), or other information that should not be public!* +Thank you for taking the time to file an issue. Here are some suggestions for writing your issue that should let us respond and help you more quickly. -**Troubleshooter Results** -Please carefully reread the [Troubleshooting Vignette](https://ouhscbbmc.github.io/REDCapR/articles/TroubleshootingApiCalls.html) and thoroughly describe which part(s) doesn't work. Many people have contributed to this document; it is likely that it will help precisely identify the location of the problem, which will help us respond with better advice. +**Troubleshooter**: Please carefully reread the [Troubleshooting Vignette](https://ouhscbbmc.github.io/REDCapR/articles/TroubleshootingApiCalls.html) and thoroughly describe which parts don't work. -If you have advice for improving the [Troubleshooter](https://ouhscbbmc.github.io/REDCapR/articles/TroubleshootingApiCalls.html) or [this issue template](https://github.com/OuhscBbmc/REDCapR/blob/master/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md), we'd love to hear about it. +**Describe the behavior**: Please provide a clear and concise description of the scenario and the behavior. *Be careful not to include tokens, PHI (protected health information), or other information that should not be public!* -**Expected behavior** -A clear and concise description of what you expected to happen. -**Screenshots** -If applicable, add screenshots to help explain your problem. +**Expected behavior**: A clear and concise description of what you expected to happen. + **Desktop (please complete the following information):** - OS: [e.g. Windows 10] @@ -27,7 +23,9 @@ If applicable, add screenshots to help explain your problem. - REDCapR Version [e.g. 0.10.2.9005 --run `packageVersion("REDCapR")`] -**Additional context** -Add any other context about the problem here. +**Additional context**: Add any other information about the specific problem, such as a data dictionary or screenshot. + -*Remember, don't include tokens, PHI, or other information that should not be public.* +**Thank you and reminder**: + * Many people have contributed to this package and it's documentation, and it's continually improving. If you have advice for improving the documentation, the [Troubleshooter](https://ouhscbbmc.github.io/REDCapR/articles/TroubleshootingApiCalls.html), or [this issue template](https://github.com/OuhscBbmc/REDCapR/blob/master/.github/ISSUE_TEMPLATE/unexpected-behavior-issue-template.md), we'd love to hear it. + * *Remember, don't include tokens, PHI, or other information that should not be public.* diff --git a/DESCRIPTION b/DESCRIPTION index f654dd0d..af53b451 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ Description: Encapsulates functions to streamline calls from R to the REDCap University. The Application Programming Interface (API) offers an avenue to access and modify data programmatically, improving the capacity for literate and reproducible programming. -Version: 0.10.2.9006 +Version: 0.11.0 Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email = "wibeasley@hotmail.com", comment = c(ORCID = "0000-0002-5613-5006")), person("David", "Bard", role = "ctb"), @@ -18,7 +18,8 @@ Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email = role = "ctb"), person("Hao", "Zhu", role = "ctb", comment = c(ORCID = '0000-0002-3386-6076')), person("Felix", "Torres", - role = "ctb", email = "fetorres@ucsd.edu")) + role = "ctb", email = "fetorres@ucsd.edu"), person("Philip", "Chase", + role = "ctb", email = "pbc@ufl.edu")) URL: https://github.com/OuhscBbmc/REDCapR, http://ouhsc.edu/bbmc/, http://project-redcap.org BugReports: https://github.com/OuhscBbmc/REDCapR/issues diff --git a/NEWS.md b/NEWS.md index d9493ca2..661dc788 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ Upcoming Versions In the future: ... -Version 0.11 (Released ?) +Version 0.11 (Released 2020-04-20) ========================================================== ### Breaking Changes (possible, but unlikely) @@ -25,7 +25,7 @@ Version 0.11 (Released ?) ### Stability Features -* `httr::content()` (which is inside `kernel_api()`) now processes the returned value as "text/csv", by default. This should prevent strange characters from tricking the process as the internal variable `raw_text` is being formed. See the [httr::content()`](https://httr.r-lib.org/reference/content.html) documentation for a list of possible values for the `content_type` parameter. (Thanks to great debugging by @vortexing, #269) +* `httr::content()` (which is inside `kernel_api()`) now processes the returned value as "text/csv", by default. This should prevent strange characters from tricking the process as the internal variable `raw_text` is being formed. See the [httr::content()`](https://httr.r-lib.org/reference/content.html) documentation for a list of possible values for the `content_type` parameter. (Thanks to great debugging by @vortexing #269, @sybandrew #272, & @begavett, #290) * Similarly, `kernel_api()` now has an `encoding` parameter, which defaults to "UTF-8". (#270) diff --git a/R/redcap-download-file-oneshot.R b/R/redcap-download-file-oneshot.R index 61538564..fc2f898d 100644 --- a/R/redcap-download-file-oneshot.R +++ b/R/redcap-download-file-oneshot.R @@ -18,6 +18,13 @@ #' Required #' @param event The name of the event where the file is saved in REDCap. #' Optional +#' @param repeat_instrument The name of the instrument that is repeating +#' for a given event. +#' Optional +#' @param repeat_instance (only for projects with repeating instruments/events) +#' The repeat instance number of the repeating event (if longitudinal) or the +#' repeating instrument (if classic or longitudinal). Default value is '1'. +#' Optional #' @param verbose A boolean value indicating if `message`s should be printed #' to the R console during the operation. Optional. #' @param config_options A list of options to pass to [httr::POST()] method @@ -101,6 +108,8 @@ redcap_download_file_oneshot <- function( record, field, event = "", + repeat_instrument = NULL, + repeat_instance = NULL, verbose = TRUE, config_options = NULL ) { @@ -132,6 +141,14 @@ redcap_download_file_oneshot <- function( if (0L < nchar(event)) post_body$event <- event + if (!is.null(repeat_instrument)) { + if (is.null(repeat_instance)) { + stop("You must specify repeat_instance when specified repeat_instrement"); + } + post_body$repeat_instrument <- repeat_instrument + post_body$repeat_instance <- repeat_instance + } + # This is the first of two important lines in the function. # It retrieves the information from the server and stores it in RAM. kernel <- kernel_api(redcap_uri, post_body, config_options) diff --git a/_pkgdown.yml b/_pkgdown.yml index 541ec157..0c387c97 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -50,6 +50,7 @@ reference: - redcap_next_free_record_name - redcap_metadata_read - redcap_metadata_write + - redcap_survey_link_export_oneshot - redcap_users_export - redcap_variables - redcap_version diff --git a/cran-comments.md b/cran-comments.md index 50d8c1d3..2f801705 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,6 @@ Description ----------------------------------------------- -This submission includes new features and also addresses some (soon-to-be) breaking changes in the libraries underneath. - -I have fixed the three points described in your previous response (documented in [our issue](https://github.com/OuhscBbmc/REDCapR/issues/253)). For the first point, I fixed some markdown syntax so the API's url is correctly interpreted. I'm sorry the test builds below didn't uncover the last two. +This submission includes new features and also addresses a recent breaking change from tibble 3.0.0 (https://github.com/OuhscBbmc/REDCapR/issues/302). Thank you for taking the time to review my submission, and please tell me if there's something else I should do for CRAN. -Will Beasley @@ -10,15 +8,15 @@ Thank you for taking the time to review my submission, and please tell me if the Test environments ----------------------------------------------- -1. Local Ubuntu, R 3.6.1 patched -1. Local Win8, R 3.6.1 patched +1. Local Ubuntu, R 3.6.3 patched +1. Local Win8, R 4.0.0 RC 1. r-hub - 1. [Ubuntu Linux 16.04 LTS, R-release, GCC](https://builder.r-hub.io/status/REDCapR_0.10.1.tar.gz-ffc36a958fe44f3fb3263929670f8138) - 1. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_0.10.1.tar.gz-2e2bed0d3cda44429a8f830c2b9d8e92) - 1. [Windows Server](https://builder.r-hub.io/status/REDCapR_0.10.1.tar.gz-0c79ee0f9b3e49f7b381348e9f7283b0) -1. [win-builder](https://win-builder.r-project.org/a9ub2IBAb24W), development version. + 1. [Ubuntu Linux 16.04 LTS, R-release, GCC](https://builder.r-hub.io/status/REDCapR_0.10.2.9006.tar.gz-71151f2f04454bc18c16430e5d62610b) + 1. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_0.10.2.9006.tar.gz-2f619028b765442f9dc1c34373443d2a) + 1. [Windows Server](https://builder.r-hub.io/status/REDCapR_0.10.2.9006.tar.gz-80133501925a411da4c3cf3be8205e29) +1. [win-builder](https://win-builder.r-project.org/xYyWrC1uFjXH), development version. 1. [Travis CI](https://travis-ci.org/OuhscBbmc/REDCapR), Ubuntu 14.04 LTS -1. [AppVeyor](https://ci.appveyor.com/project/wibeasley/REDCapR), Windows Server 2012 +1. [AppVeyor](https://ci.appveyor.com/project/wibeasley/REDCapR), Windows Server 2012 R2 R CMD check results diff --git a/docs/404.html b/docs/404.html index 28be2bff..49fa6436 100644 --- a/docs/404.html +++ b/docs/404.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,15 +46,14 @@ - + - - + @@ -68,7 +71,7 @@ - +
@@ -97,26 +100,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -124,7 +109,7 @@
  • + + @@ -165,7 +156,7 @@

    Page not found (404)

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/CONDUCT.html b/docs/CONDUCT.html index 31b27e3c..8d643a98 100644 --- a/docs/CONDUCT.html +++ b/docs/CONDUCT.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,15 +46,14 @@ - + - - + @@ -68,7 +71,7 @@ - +
    @@ -97,26 +100,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -124,7 +109,7 @@
  • + + @@ -173,7 +164,7 @@

    Contributor Code of Conduct

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/apple-touch-icon-120x120.png b/docs/apple-touch-icon-120x120.png new file mode 100644 index 00000000..c357b368 Binary files /dev/null and b/docs/apple-touch-icon-120x120.png differ diff --git a/docs/apple-touch-icon-152x152.png b/docs/apple-touch-icon-152x152.png new file mode 100644 index 00000000..1ba80381 Binary files /dev/null and b/docs/apple-touch-icon-152x152.png differ diff --git a/docs/apple-touch-icon-180x180.png b/docs/apple-touch-icon-180x180.png new file mode 100644 index 00000000..5d9ce0e5 Binary files /dev/null and b/docs/apple-touch-icon-180x180.png differ diff --git a/docs/apple-touch-icon-60x60.png b/docs/apple-touch-icon-60x60.png new file mode 100644 index 00000000..6efeee7d Binary files /dev/null and b/docs/apple-touch-icon-60x60.png differ diff --git a/docs/apple-touch-icon-76x76.png b/docs/apple-touch-icon-76x76.png new file mode 100644 index 00000000..5ba4fa2f Binary files /dev/null and b/docs/apple-touch-icon-76x76.png differ diff --git a/docs/apple-touch-icon.png b/docs/apple-touch-icon.png new file mode 100644 index 00000000..3d879866 Binary files /dev/null and b/docs/apple-touch-icon.png differ diff --git a/docs/articles/BasicREDCapROperations.html b/docs/articles/BasicREDCapROperations.html index 7ea98e5b..9735b0ac 100644 --- a/docs/articles/BasicREDCapROperations.html +++ b/docs/articles/BasicREDCapROperations.html @@ -12,22 +12,22 @@ - - - - - + + + + + + - - - + + - +

    Read all records and fields

    If no information is passed about the desired records or fields, then the entire data set is returned. Only two parameters are required, redcap_uri and token. Unless the verbose parameter is set to FALSE, a message will be printed on the R console with the number of records and fields returned.

    -
    #Return all records and all variables.
    -ds_all_rows_all_fields <- redcap_read(redcap_uri=uri, token=token)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.5 seconds.  The http status code was 200.
    -
    5 records and 1 columns were read from REDCap in 0.4 seconds.  The http status code was 200.
    -
    Starting to read 5 records  at 2020-02-18 10:35:33.
    +
    # Return all records and all variables.
    +ds_all_rows_all_fields <- redcap_read(redcap_uri = uri, token = token)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.4 seconds.  The http status code was 200.
    +
    5 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    Starting to read 5 records  at 2020-04-19 13:31:36.
    Reading batch 1 of 1, with subjects 1 through 5 (ie, 5 unique subject records).
    -
    5 records and 24 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    5 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       .default = col_double(),
    @@ -155,7 +137,7 @@ 

    mugshot = col_character() )

    See spec(...) for full column specifications.
    -
    ds_all_rows_all_fields #Inspect the returned dataset
    +
    ds_all_rows_all_fields # Inspect the returned dataset
      record_id name_first name_last                                 address
     1         1     Nutmeg  Nutmouse 14 Rose Cottage St.\nKenning UK, 323232
     2         2     Tumtum  Nutmouse 14 Rose Cottage Blvd.\nKenning UK 34243
    @@ -198,18 +180,18 @@ 

    Read a subset of the records

    If only a subset of the records is desired, the two approaches are shown below. The first is to pass an array (where each element is an ID) to the records parameter. The second is to pass a single string (where the elements are separated by commas) to the records_collapsed parameter.

    The first format is more natural for more R users. The second format is what is expected by the REDCap API. If a value for records is specified, but records_collapsed is not specified, then redcap_read_oneshot automatically converts the array into the format needed by the API.

    -
    #Return only records with IDs of 1 and 3
    -desired_records_v1 <- c(1, 3)
    -ds_some_rows_v1 <- redcap_read(
    -   redcap_uri = uri,
    -   token      = token,
    -   records    = desired_records_v1
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    2 records and 1 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    Starting to read 2 records  at 2020-02-18 10:35:35.
    +
    # Return only records with IDs of 1 and 3
    +desired_records_v1 <- c(1, 3)
    +ds_some_rows_v1 <- redcap_read(
    +  redcap_uri = uri,
    +  token      = token,
    +  records    = desired_records_v1
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    2 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    Starting to read 2 records  at 2020-04-19 13:31:37.
    Reading batch 1 of 1, with subjects 1 through 3 (ie, 2 unique subject records).
    -
    2 records and 24 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    2 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       .default = col_double(),
    @@ -223,18 +205,18 @@ 

    mugshot = col_character() )

    See spec(...) for full column specifications.
    -
    #Return only records with IDs of 1 and 3 (alternate way)
    -desired_records_v2 <- "1, 3"
    -ds_some_rows_v2 <- redcap_read(
    -   redcap_uri        = uri,
    -   token             = token,
    -   records_collapsed = desired_records_v2
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    2 records and 1 columns were read from REDCap in 0.7 seconds.  The http status code was 200.
    -
    Starting to read 2 records  at 2020-02-18 10:35:37.
    +
    # Return only records with IDs of 1 and 3 (alternate way)
    +desired_records_v2 <- "1, 3"
    +ds_some_rows_v2 <- redcap_read(
    +  redcap_uri        = uri,
    +  token             = token,
    +  records_collapsed = desired_records_v2
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    2 records and 1 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    Starting to read 2 records  at 2020-04-19 13:31:38.
    Reading batch 1 of 1, with subjects 1 through 3 (ie, 2 unique subject records).
    -
    2 records and 24 columns were read from REDCap in 0.4 seconds.  The http status code was 200.
    +
    2 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       .default = col_double(),
    @@ -248,7 +230,7 @@ 

    mugshot = col_character() )

    See spec(...) for full column specifications.
    -
    ds_some_rows_v2 #Inspect the returned dataset
    +
    ds_some_rows_v2 # Inspect the returned dataset
      record_id name_first name_last                                 address
     1         1     Nutmeg  Nutmouse 14 Rose Cottage St.\nKenning UK, 323232
     2         3     Marcus      Wood          243 Hill St.\nGuthrie OK 73402
    @@ -269,43 +251,43 @@ 

    Read a subset of the fields

    If only a subset of the fields is desired, then two approaches exist. The first is to pass an array (where each element is an field) to the fields parameter. The second is to pass a single string (where the elements are separated by commas) to the fields_collapsed parameter. Like with records and records_collapsed described above, this function converts the more natural format (i.e., fields) to the format required by the API (ie, fields_collapsed) if fields is specified and fields_collapsed is not.

    -
    #Return only the fields record_id, name_first, and age
    -desired_fields_v1 <- c("record_id", "name_first", "age")
    -ds_some_fields_v1 <- redcap_read(
    -   redcap_uri = uri,
    -   token      = token,
    -   fields     = desired_fields_v1
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    #Return only the fields record_id, name_first, and age
    +desired_fields_v1 <- c("record_id", "name_first", "age")
    +ds_some_fields_v1 <- redcap_read(
    +  redcap_uri = uri,
    +  token      = token,
    +  fields     = desired_fields_v1
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    5 records and 1 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    Starting to read 5 records  at 2020-02-18 10:35:38.
    +
    Starting to read 5 records  at 2020-04-19 13:31:40.
    Reading batch 1 of 1, with subjects 1 through 5 (ie, 5 unique subject records).
    -
    5 records and 3 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    5 records and 3 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       record_id = col_double(),
       name_first = col_character(),
       age = col_double()
     )
    -
    #Return only the fields record_id, name_first, and age (alternate way)
    -desired_fields_v2 <- "record_id, name_first, age"
    -ds_some_fields_v2 <- redcap_read(
    -   redcap_uri       = uri,
    -   token            = token,
    -   fields_collapsed = desired_fields_v2
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    5 records and 1 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    Starting to read 5 records  at 2020-02-18 10:35:40.
    +
    #Return only the fields record_id, name_first, and age (alternate way)
    +desired_fields_v2 <- "record_id, name_first, age"
    +ds_some_fields_v2 <- redcap_read(
    +  redcap_uri       = uri,
    +  token            = token,
    +  fields_collapsed = desired_fields_v2
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    5 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    Starting to read 5 records  at 2020-04-19 13:31:41.
    Reading batch 1 of 1, with subjects 1 through 5 (ie, 5 unique subject records).
    -
    5 records and 3 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    5 records and 3 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       record_id = col_double(),
       name_first = col_character(),
       age = col_double()
     )
    -
    ds_some_fields_v2 #Inspect the returned dataset
    +
    ds_some_fields_v2 #Inspect the returned dataset
      record_id name_first age
     1         1     Nutmeg  11
     2         2     Tumtum  11
    @@ -317,51 +299,51 @@ 

    Read a subset of records, conditioned on the values in some variables

    The two techniques above can be combined when your datasets are large and you don’t want to pull records with certain values. Suppose you want to select subjects from the previous dataset if the were born before 1960 and their weight was over 70kg. Two calls to the server are required. The first call to REDCap pulls all the records, but for only three columns: record_id, dob, and weight. From this subset, identify the records that you want to pull all the data for; in this case, the desired record_id values are 3 & 5. The second call to REDCap pulls all the columns, but only for the identified records.

    -
    ######
    -## Step 1: First call to REDCap
    -desired_fields_v3 <- c("record_id", "dob", "weight")
    -ds_some_fields_v3 <- redcap_read(
    -   redcap_uri = uri,
    -   token      = token,
    -   fields     = desired_fields_v3
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    ######
    +## Step 1: First call to REDCap
    +desired_fields_v3 <- c("record_id", "dob", "weight")
    +ds_some_fields_v3 <- redcap_read(
    +  redcap_uri = uri,
    +  token      = token,
    +  fields     = desired_fields_v3
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    5 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    -
    Starting to read 5 records  at 2020-02-18 10:35:41.
    +
    Starting to read 5 records  at 2020-04-19 13:31:42.
    Reading batch 1 of 1, with subjects 1 through 5 (ie, 5 unique subject records).
    -
    5 records and 3 columns were read from REDCap in 0.4 seconds.  The http status code was 200.
    +
    5 records and 3 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       record_id = col_double(),
       dob = col_date(format = ""),
       weight = col_double()
     )
    -
    ds_some_fields_v3 #Examine the these three variables.
    +
    ds_some_fields_v3 #Examine the these three variables.
      record_id        dob weight
     1         1 2003-08-30      1
     2         2 2003-03-10      1
     3         3 1934-04-09     80
     4         4 1952-11-02     54
     5         5 1955-04-15    104
    -
    ######
    -## Step 2: identify desired records, based on age & weight
    -before_1960 <- (ds_some_fields_v3$dob <= as.Date("1960-01-01"))
    -heavier_than_70_kg <- (ds_some_fields_v3$weight > 70)
    -desired_records_v3 <- ds_some_fields_v3[before_1960 & heavier_than_70_kg, ]$record_id
    -
    -desired_records_v3 #Peek at IDs of the identified records
    +
    ######
    +## Step 2: identify desired records, based on age & weight
    +before_1960 <- (ds_some_fields_v3$dob <= as.Date("1960-01-01"))
    +heavier_than_70_kg <- (ds_some_fields_v3$weight > 70)
    +desired_records_v3 <- ds_some_fields_v3[before_1960 & heavier_than_70_kg, ]$record_id
    +
    +desired_records_v3 #Peek at IDs of the identified records
    [1] 3 5
    -
    ######
    -## Step 3: second call to REDCap
    -#Return only records that met the age & weight criteria.
    -ds_some_rows_v3 <- redcap_read(
    -   redcap_uri = uri,
    -   token      = token,
    -   records    = desired_records_v3
    -)$data
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    2 records and 1 columns were read from REDCap in 0.4 seconds.  The http status code was 200.
    -
    Starting to read 2 records  at 2020-02-18 10:35:43.
    +
    ######
    +## Step 3: second call to REDCap
    +#Return only records that met the age & weight criteria.
    +ds_some_rows_v3 <- redcap_read(
    +  redcap_uri = uri,
    +  token      = token,
    +  records    = desired_records_v3
    +)$data
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    2 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    Starting to read 2 records  at 2020-04-19 13:31:44.
    Reading batch 1 of 1, with subjects 3 through 5 (ie, 2 unique subject records).
    2 records and 24 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    Parsed with column specification:
    @@ -377,7 +359,7 @@ 

    mugshot = col_character() )

    See spec(...) for full column specifications.
    -
    ds_some_rows_v3 #Examine the results.
    +
    ds_some_rows_v3 #Examine the results.
      record_id name_first name_last                            address
     1         3     Marcus      Wood     243 Hill St.\nGuthrie OK 73402
     2         5   John Lee    Walker Hotel Suite\nNew Orleans LA, 70115
    @@ -410,24 +392,24 @@ 

  • The fields_collapsed fields passed to the API. This shows which field subsets, if any, were requested.
  • The elapsed_seconds measures the duration of the call.
  • -
    #Return only the fields record_id, name_first, and age
    -all_information <- redcap_read(
    -   redcap_uri = uri,
    -   token      = token,
    -   fields     = desired_fields_v1
    -)
    -
    The data dictionary describing 16 fields was read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    5 records and 1 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    Starting to read 5 records  at 2020-02-18 10:35:44.
    +
    #Return only the fields record_id, name_first, and age
    +all_information <- redcap_read(
    +  redcap_uri = uri,
    +  token      = token,
    +  fields     = desired_fields_v1
    +)
    +
    The data dictionary describing 16 fields was read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    5 records and 1 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    Starting to read 5 records  at 2020-04-19 13:31:45.
    Reading batch 1 of 1, with subjects 1 through 5 (ie, 5 unique subject records).
    -
    5 records and 3 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    +
    5 records and 3 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    Parsed with column specification:
     cols(
       record_id = col_double(),
       name_first = col_character(),
       age = col_double()
     )
    -
    all_information #Inspect the additional information
    +
    all_information #Inspect the additional information
    $data
       record_id name_first age
     1         1     Nutmeg  11
    @@ -443,7 +425,7 @@ 

    [1] "200" $outcome_messages -[1] "5 records and 3 columns were read from REDCap in 0.3 seconds. The http status code was 200." +[1] "5 records and 3 columns were read from REDCap in 0.2 seconds. The http status code was 200." $records_collapsed [1] "" @@ -461,7 +443,7 @@

    [1] "" $elapsed_seconds -[1] 1.400878

    +[1] 1.284016

    @@ -471,7 +453,7 @@

    Environment

    ─ Session info ───────────────────────────────────────────────────────────────
      setting  value                       
    - version  R version 3.6.2 (2019-12-12)
    + version  R version 3.6.3 (2020-02-29)
      os       Ubuntu 19.10                
      system   x86_64, linux-gnu           
      ui       X11                         
    @@ -479,102 +461,76 @@ 

    collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Chicago - date 2020-02-18 + date 2020-04-19 ─ Packages ─────────────────────────────────────────────────────────────────── package * version date lib source assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.1) - backports 1.1.5 2019-10-02 [2] CRAN (R 3.6.1) - callr 3.4.2 2020-02-12 [2] CRAN (R 3.6.2) + backports 1.1.6 2020-04-05 [2] CRAN (R 3.6.3) checkmate 2.0.0 2019-12-03 [2] local - cli 2.0.1 2020-01-08 [2] CRAN (R 3.6.1) + cli 2.0.2 2020-02-28 [2] CRAN (R 3.6.2) colorspace 1.4-1 2019-03-18 [2] CRAN (R 3.6.1) crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.1) curl 4.3 2019-12-02 [2] CRAN (R 3.6.1) desc 1.2.0 2018-05-01 [2] CRAN (R 3.6.1) - devtools 2.2.1 2019-09-24 [2] CRAN (R 3.6.1) - digest 0.6.24 2020-02-12 [2] CRAN (R 3.6.2) - dplyr 0.8.4 2020-01-31 [2] CRAN (R 3.6.2) + digest 0.6.25 2020-02-23 [2] CRAN (R 3.6.2) + dplyr 0.8.5 2020-03-07 [2] CRAN (R 3.6.3) ellipsis 0.3.0 2019-09-20 [2] CRAN (R 3.6.1) evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.1) fansi 0.4.1 2020-01-08 [2] CRAN (R 3.6.1) - fs 1.3.1 2019-05-06 [2] CRAN (R 3.6.1) - glue 1.3.1 2019-03-12 [2] CRAN (R 3.6.1) + fs 1.4.1 2020-04-04 [2] CRAN (R 3.6.3) + glue 1.4.0 2020-04-03 [2] CRAN (R 3.6.3) hms 0.5.3 2020-01-08 [2] CRAN (R 3.6.1) htmltools 0.4.0 2019-10-04 [2] CRAN (R 3.6.1) httr 1.4.1 2019-08-05 [2] CRAN (R 3.6.1) kableExtra 1.1.0 2019-03-16 [2] CRAN (R 3.6.1) knitr * 1.28 2020-02-06 [2] CRAN (R 3.6.2) - lifecycle 0.1.0 2019-08-01 [2] CRAN (R 3.6.1) + lifecycle 0.2.0 2020-03-06 [2] CRAN (R 3.6.3) magrittr * 1.5 2014-11-22 [2] CRAN (R 3.6.1) MASS 7.3-51.5 2019-12-20 [5] CRAN (R 3.6.2) memoise 1.1.0 2017-04-21 [2] CRAN (R 3.6.1) munsell 0.5.0 2018-06-12 [2] CRAN (R 3.6.1) pillar 1.4.3 2019-12-20 [2] CRAN (R 3.6.1) - pkgbuild 1.0.6 2019-10-09 [2] CRAN (R 3.6.1) pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 3.6.1) - pkgdown 1.4.1 2019-09-15 [2] CRAN (R 3.6.1) - pkgload 1.0.2 2018-10-29 [2] CRAN (R 3.6.1) - prettyunits 1.1.1 2020-01-24 [2] CRAN (R 3.6.2) - processx 3.4.2 2020-02-09 [2] CRAN (R 3.6.2) - ps 1.3.2 2020-02-13 [2] CRAN (R 3.6.2) + pkgdown 1.5.0 2020-03-25 [2] CRAN (R 3.6.3) purrr 0.3.3 2019-10-18 [2] CRAN (R 3.6.1) R6 2.4.1 2019-11-12 [2] CRAN (R 3.6.1) - Rcpp 1.0.3 2019-11-08 [2] CRAN (R 3.6.1) + Rcpp 1.0.4 2020-03-17 [2] CRAN (R 3.6.3) readr 1.3.1 2018-12-21 [2] CRAN (R 3.6.1) - REDCapR * 0.10.2.9005 2020-02-18 [1] local - remotes 2.1.1 2020-02-15 [2] CRAN (R 3.6.2) - rlang 0.4.4 2020-01-28 [2] CRAN (R 3.6.2) + REDCapR * 0.10.2.9006 2020-04-19 [1] local + rlang 0.4.5 2020-03-01 [2] CRAN (R 3.6.2) rmarkdown 2.1 2020-01-20 [2] CRAN (R 3.6.2) rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.6.1) rstudioapi 0.11 2020-02-07 [2] CRAN (R 3.6.2) rvest 0.3.5 2019-11-08 [2] CRAN (R 3.6.1) scales 1.1.0 2019-11-18 [2] CRAN (R 3.6.1) sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 3.6.1) - stringi 1.4.5 2020-01-11 [2] CRAN (R 3.6.1) + stringi 1.4.6 2020-02-17 [2] CRAN (R 3.6.2) stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.1) - testthat 2.3.1 2019-12-01 [2] CRAN (R 3.6.1) - tibble 2.1.3 2019-06-06 [2] CRAN (R 3.6.1) + tibble 3.0.0 2020-03-30 [2] CRAN (R 3.6.3) tidyselect 1.0.0 2020-01-27 [2] CRAN (R 3.6.2) - usethis 1.5.1 2019-07-04 [2] CRAN (R 3.6.1) - vctrs 0.2.2 2020-01-24 [2] CRAN (R 3.6.2) + vctrs 0.2.4 2020-03-10 [2] CRAN (R 3.6.3) viridisLite 0.3.0 2018-02-01 [2] CRAN (R 3.6.1) webshot 0.5.2 2019-11-22 [2] CRAN (R 3.6.1) withr 2.1.2 2018-03-15 [2] CRAN (R 3.6.1) xfun 0.12 2020-01-13 [2] CRAN (R 3.6.1) - xml2 1.2.2 2019-08-09 [2] CRAN (R 3.6.1) + xml2 1.3.0 2020-04-01 [2] CRAN (R 3.6.3) yaml 2.2.1 2020-02-01 [2] CRAN (R 3.6.2) -[1] /tmp/RtmpQwpj1Q/temp_libpath20fe13c92d77 +[1] /tmp/Rtmp5avAp4/temp_libpath4e6a183ad817 [2] /home/wibeasley/R/x86_64-pc-linux-gnu-library/3.6 [3] /usr/local/lib/R/site-library [4] /usr/lib/R/site-library [5] /usr/lib/R/library

    -

    Report rendered by wibeasley at 2020-02-18, 10:35 -0600 in 15 seconds.

    +

    Report rendered by wibeasley at 2020-04-19, 13:31 -0500 in 15 seconds.

    - @@ -585,7 +541,7 @@

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/articles/SecurityDatabase.html b/docs/articles/SecurityDatabase.html index 360ce19f..27c5a7de 100644 --- a/docs/articles/SecurityDatabase.html +++ b/docs/articles/SecurityDatabase.html @@ -12,22 +12,22 @@ - - - - - + + + + + + - - - + + - +

    @@ -444,22 +343,11 @@

    - @@ -470,7 +358,7 @@

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/articles/TroubleshootingApiCalls.html b/docs/articles/TroubleshootingApiCalls.html index b1ee5f83..c286a245 100644 --- a/docs/articles/TroubleshootingApiCalls.html +++ b/docs/articles/TroubleshootingApiCalls.html @@ -12,22 +12,22 @@ - - - - - + + + + + + - - - + + - +
    - @@ -564,7 +517,7 @@

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/articles/advanced-redcapr-operations.html b/docs/articles/advanced-redcapr-operations.html index 98ef4a33..98d88ac2 100644 --- a/docs/articles/advanced-redcapr-operations.html +++ b/docs/articles/advanced-redcapr-operations.html @@ -12,22 +12,22 @@ - - - - - + + + + + + - - - + + - +

    Converting from tall/long to wide

    Disclaimer: Occasionally we’re asked for a longitudinal dataset to be converted from a “long/tall format” (where typically each row is one observation for a participant) to a “wide format” (where each row is on participant). Usually we advise against it. Besides all the database benefits of a long structure, a wide structure restricts your options with the stat routine. No modern longitudinal analysis procedures (e.g., growth curve models or multilevel/hierarchical models) accept wide. You’re pretty much stuck with repeated measures anova, which is very inflexible for real-world medical-ish analyses. It requires a patient to have a measurement at every time point; otherwise the anova excludes the patient entirely.

    However we like going wide to produce visual tables for publications, and here’s one way to do it in R. First retrieve the dataset from REDCap.

    -
    library(magrittr);
    -suppressPackageStartupMessages(requireNamespace("dplyr"))
    -suppressPackageStartupMessages(requireNamespace("tidyr"))
    -events_to_retain  <- c("dose_1_arm_1", "visit_1_arm_1", "dose_2_arm_1", "visit_2_arm_1")
    -
    -ds_long <- REDCapR::redcap_read_oneshot(redcap_uri=uri, token=token_longitudinal)$data
    -
    #> 18 records and 125 columns were read from REDCap in 0.6 seconds.  The http status code was 200.
    -
    ds_long %>%
    -  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4)
    +
    library(magrittr);
    +suppressPackageStartupMessages(requireNamespace("dplyr"))
    +suppressPackageStartupMessages(requireNamespace("tidyr"))
    +events_to_retain  <- c("dose_1_arm_1", "visit_1_arm_1", "dose_2_arm_1", "visit_2_arm_1")
    +
    +ds_long <- REDCapR::redcap_read_oneshot(redcap_uri = uri, token = token_longitudinal)$data
    +
    #> 18 records and 125 columns were read from REDCap in 0.5 seconds.  The http status code was 200.
    +
    ds_long %>%
    +  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4)
    #>    study_id        redcap_event_name pmq1 pmq2 pmq3 pmq4
     #> 1       100         enrollment_arm_1   NA   NA   NA   NA
     #> 2       100             dose_1_arm_1    2    2    1    1
    @@ -166,44 +148,44 @@ 

    #> 17 304 final_visit_arm_2 NA NA NA NA #> 18 304 deadline_to_return_arm_2 NA NA NA NA

    When widening only one variable (e.g., pmq1), the code’s pretty simple:

    -
    ds_wide <-
    -  ds_long %>%
    -  dplyr::select(study_id, redcap_event_name, pmq1) %>%
    -  dplyr::filter(redcap_event_name %in% events_to_retain) %>%
    -  tidyr::pivot_wider(
    -    id_cols     = study_id,
    -    names_from  = redcap_event_name,
    -    values_from = pmq1
    -  )
    -  # For old versions of tidyr that predate `pivot_wider()`:
    -  # tidyr::spread(key=redcap_event_name, value=pmq1)
    -ds_wide
    +
    ds_wide <-
    +  ds_long %>%
    +  dplyr::select(study_id, redcap_event_name, pmq1) %>%
    +  dplyr::filter(redcap_event_name %in% events_to_retain) %>%
    +  tidyr::pivot_wider(
    +    id_cols     = study_id,
    +    names_from  = redcap_event_name,
    +    values_from = pmq1
    +  )
    +  # For old versions of tidyr that predate `pivot_wider()`:
    +  # tidyr::spread(key=redcap_event_name, value=pmq1)
    +ds_wide
    #> # A tibble: 2 x 5
     #>   study_id dose_1_arm_1 visit_1_arm_1 dose_2_arm_1 visit_2_arm_1
     #>      <dbl>        <dbl>         <dbl>        <dbl>         <dbl>
     #> 1      100            2             1            3             0
     #> 2      220            0             0            1             3

    In some scenarios, multiple variables (e.g., pmq1 - pmq4) can be widened in a single tidyr::pivot_wider() operation. This example contains the additional wrinkle that the REDCap event names “first_dose” and “first_visit” are renamed “dose_1” and “visit_1”, which will help all the values be dose and visit values be proper numbers.

    -
    pattern <- "^(\\w+?)_arm_(\\d)$"
    -ds_wide <-
    -  ds_long %>%
    -  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4) %>%
    -  dplyr::mutate(
    -    event = sub(pattern, "\\1", redcap_event_name),
    -    event = dplyr::recode(event, "first_dose"="dose_1", "first_visit"="visit_1"),
    -    arm   = as.integer(sub(pattern, "\\2", redcap_event_name))
    -  ) %>%
    -  dplyr::select(study_id, event, arm, pmq1, pmq2, pmq3, pmq4) %>%
    -  dplyr::filter(!(event %in% c(
    -    "enrollment", "final_visit", "deadline_to_return", "deadline_to_opt_ou")
    -  )) %>%
    -  tidyr::pivot_wider(
    -    id_cols     = c(study_id, arm),
    -    names_from  = event,
    -    values_from = c(pmq1, pmq2, pmq3, pmq4)
    -  )
    -
    -ds_wide
    +
    pattern <- "^(\\w+?)_arm_(\\d)$"
    +ds_wide <-
    +  ds_long %>%
    +  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4) %>%
    +  dplyr::mutate(
    +    event = sub(pattern, "\\1", redcap_event_name),
    +    event = dplyr::recode(event, "first_dose"="dose_1", "first_visit"="visit_1"),
    +    arm   = as.integer(sub(pattern, "\\2", redcap_event_name))
    +  ) %>%
    +  dplyr::select(study_id, event, arm, pmq1, pmq2, pmq3, pmq4) %>%
    +  dplyr::filter(!(event %in% c(
    +    "enrollment", "final_visit", "deadline_to_return", "deadline_to_opt_ou")
    +  )) %>%
    +  tidyr::pivot_wider(
    +    id_cols     = c(study_id, arm),
    +    names_from  = event,
    +    values_from = c(pmq1, pmq2, pmq3, pmq4)
    +  )
    +
    +ds_wide
    #> # A tibble: 3 x 18
     #>   study_id   arm pmq1_dose_1 pmq1_visit_1 pmq1_dose_2 pmq1_visit_2 pmq2_dose_1
     #>      <dbl> <int>       <dbl>        <dbl>       <dbl>        <dbl>       <dbl>
    @@ -215,33 +197,33 @@ 

    #> # pmq3_dose_2 <dbl>, pmq3_visit_2 <dbl>, pmq4_dose_1 <dbl>, #> # pmq4_visit_1 <dbl>, pmq4_dose_2 <dbl>, pmq4_visit_2 <dbl>

    However, in other widening scenarios, it can be easier to go even longer/taller (e.g., ds_eav) before reversing direction and going wide.

    -
    ds_eav <-
    -  ds_long %>%
    -  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4) %>%
    -  dplyr::mutate(
    -    event = sub(pattern, "\\1", redcap_event_name),
    -    event = dplyr::recode(event, "first_dose"="dose_1", "first_visit"="visit_1"),
    -    arm   = as.integer(sub(pattern, "\\2", redcap_event_name))
    -  ) %>%
    -  dplyr::select(study_id, event, arm, pmq1, pmq2, pmq3, pmq4) %>%
    -  tidyr::pivot_longer(
    -    cols      = c(pmq1, pmq2, pmq3, pmq4),
    -    names_to  = "key",
    -    values_to = "value"
    -  ) %>%
    -  # For old versions of tidyr that predate `pivot_wider()`:
    -  # tidyr::gather(key=key, value=value, pmq1, pmq2, pmq3, pmq4) %>%
    -  dplyr::filter(!(event %in% c(
    -    "enrollment", "final_visit", "deadline_to_return", "deadline_to_opt_ou")
    -  )) %>%
    -  dplyr::mutate( # Simulate correcting for mismatched names across arms:
    -    key = paste0(key, "_", event)
    -  ) %>%
    -  dplyr::select(-event)
    -
    -# Show the first 10 rows of the EAV table.
    -ds_eav %>%
    -  head(10)
    +
    ds_eav <-
    +  ds_long %>%
    +  dplyr::select(study_id, redcap_event_name, pmq1, pmq2, pmq3, pmq4) %>%
    +  dplyr::mutate(
    +    event = sub(pattern, "\\1", redcap_event_name),
    +    event = dplyr::recode(event, "first_dose" = "dose_1", "first_visit" = "visit_1"),
    +    arm   = as.integer(sub(pattern, "\\2", redcap_event_name))
    +  ) %>%
    +  dplyr::select(study_id, event, arm, pmq1, pmq2, pmq3, pmq4) %>%
    +  tidyr::pivot_longer(
    +    cols      = c(pmq1, pmq2, pmq3, pmq4),
    +    names_to  = "key",
    +    values_to = "value"
    +  ) %>%
    +  # For old versions of tidyr that predate `pivot_wider()`:
    +  # tidyr::gather(key=key, value=value, pmq1, pmq2, pmq3, pmq4) %>%
    +  dplyr::filter(!(event %in% c(
    +    "enrollment", "final_visit", "deadline_to_return", "deadline_to_opt_ou")
    +  )) %>%
    +  dplyr::mutate( # Simulate correcting for mismatched names across arms:
    +    key = paste0(key, "_", event)
    +  ) %>%
    +  dplyr::select(-event)
    +
    +# Show the first 10 rows of the EAV table.
    +ds_eav %>%
    +  head(10)
    #> # A tibble: 10 x 4
     #>    study_id   arm key          value
     #>       <dbl> <int> <chr>        <dbl>
    @@ -255,17 +237,17 @@ 

    #> 8 100 1 pmq4_visit_1 0 #> 9 100 1 pmq1_dose_2 3 #> 10 100 1 pmq2_dose_2 1

    -
    # Spread the EAV to wide.
    -ds_wide_2 <-
    -  ds_eav %>%
    -  tidyr::pivot_wider(
    -    id_cols     = c(study_id, arm),
    -    names_from  = key,
    -    values_from = value
    -  )
    -  # For old versions of tidyr that predate `pivot_wider()`:
    -  # tidyr::spread(key=key, value=value)
    -ds_wide_2
    +
    # Spread the EAV to wide.
    +ds_wide_2 <-
    +  ds_eav %>%
    +  tidyr::pivot_wider(
    +    id_cols     = c(study_id, arm),
    +    names_from  = key,
    +    values_from = value
    +  )
    +  # For old versions of tidyr that predate `pivot_wider()`:
    +  # tidyr::spread(key=key, value=value)
    +ds_wide_2
    #> # A tibble: 3 x 18
     #>   study_id   arm pmq1_dose_1 pmq2_dose_1 pmq3_dose_1 pmq4_dose_1 pmq1_visit_1
     #>      <dbl> <int>       <dbl>       <dbl>       <dbl>       <dbl>        <dbl>
    @@ -278,35 +260,64 @@ 

    #> # pmq2_visit_2 <dbl>, pmq3_visit_2 <dbl>, pmq4_visit_2 <dbl>

    Lots of packages and documentation exist. Our current preference is the tidyverse approach to pivoting, but the data.table approach is worth considering if you’re comfortable with that package. This Stack Overflow post describes several ways. We recommend against the reshape and reshape2 packages, because their developers have replaced them with the tidyr functions described above.

    +
    +

    +Query the Underlying MySQL Database

    +

    If you require a feature that is not available from your instance’s API, first upgrade your institution’s REDcap instance and see if the feature has been added recently. Second, check if someone has released the desired API-like features as an REDCap External Module.

    +

    Third, you may need to query the database underneath REDCap’s web server. The Transfer Credentials section of the Security Database Vignette provides a complete example of using R to query the MySQL database through odbc.

    +

    We find it’s best to develop the query in MySQL Workbench, then copy the code to R (or alternatively, use OuhscMunge::execute_sql_file()).

    +

    Here is an example that retrieves the first_submit_time, which is helpful if you need a timestamp from surveys that were not marked as completed. Replace ‘444’ with your pid, and 1001 through 1003 with the desired events.

    +
    SELECT 
    +  p.participant_id      as participant_survey_id
    +  ,r.record             as record_id
    +  ,p.event_id
    +  ,e.descrip            as event_name
    +  ,r.first_submit_time
    +  ,r.completion_time
    +  
    +  -- ,p.*
    +  -- ,r.*
    +FROM redcapv3.redcap_surveys_participants     as p
    +  left  join redcapv3.redcap_surveys_response as r on p.participant_id = r.participant_id
    +  left  join redcapv3.redcap_events_metadata  as e on p.event_id       = e.event_id
    +where 
    +  p.survey_id = 444
    +  and
    +  p.event_id in (
    +    1001, -- start of the year
    +    1002, -- mid term
    +    1003  -- end of year
    +  )
    +

    SSL Options

    The official cURL site discusses the process of using SSL to verify the server being connected to.

    Use the SSL cert file that come with the openssl package.

    -
    cert_location <- system.file("cacert.pem", package="openssl")
    -if( file.exists(cert_location) ) {
    -  config_options         <- list(cainfo=cert_location)
    -  ds_different_cert_file <- redcap_read_oneshot(
    -    redcap_uri     = uri,
    -    token          = token_simple,
    -    config_options = config_options
    -  )$data
    -}
    +
    cert_location <- system.file("cacert.pem", package = "openssl")
    +if (file.exists(cert_location)) {
    +  config_options         <- list(cainfo = cert_location)
    +  ds_different_cert_file <- redcap_read_oneshot(
    +    redcap_uri     = uri,
    +    token          = token_simple,
    +    config_options = config_options
    +  )$data
    +}
    #> 5 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.

    Force the connection to use SSL=3 (which is not preferred, and possibly insecure).

    -
    config_options <- list(sslversion=3)
    -ds_ssl_3 <- redcap_read_oneshot(
    -  redcap_uri     = uri,
    -  token          = token_simple,
    -  config_options = config_options
    -)$data
    -
    #> 5 records and 24 columns were read from REDCap in 0.3 seconds.  The http status code was 200.
    -
    config_options <- list(ssl.verifypeer=FALSE)
    -ds_no_ssl <- redcap_read_oneshot(
    -   redcap_uri     = uri,
    -   token          = token_simple,
    -   config_options = config_options
    -)$data
    +
    config_options <- list(sslversion = 3)
    +ds_ssl_3 <- redcap_read_oneshot(
    +  redcap_uri     = uri,
    +  token          = token_simple,
    +  config_options = config_options
    +)$data
    +
    #> 5 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    +
    config_options <- list(ssl.verifypeer = FALSE)
    +ds_no_ssl <- redcap_read_oneshot(
    +  redcap_uri     = uri,
    +  token          = token_simple,
    +  config_options = config_options
    +)$data
    #> 5 records and 24 columns were read from REDCap in 0.2 seconds.  The http status code was 200.
    @@ -325,35 +336,6 @@

    SEX 0, Male | 1, Female LANGUAGE 1, English | 2, Spanish | 3, Other | 6, Unknown

    -
    -

    -Query the Underlying MySQL Database

    -

    If you require a feature that is not available from your instance’s API, first upgrade your institution’s REDcap instance and see if the feature has been added recently. Second, check if someone has released the desired API-like features as an REDCap External Module.

    -

    Third, you may need to query the database underneath REDCap’s web server. The Transfer Credentials section of the Security Database Vignette provides a complete example of using R to query the MySQL database through odbc.

    -

    We find it’s best to develop the query in MySQL Workbench, then copy the code to R (or alternatively, use OuhscMunge::execute_sql_file()).

    -

    Here is an example that retrieves the first_submit_time, which is helpful if you need a timestamp from surveys that were not marked as completed. Replace ‘444’ with your pid, and 1001 through 1003 with the desired events.

    -
    SELECT 
    -  p.participant_id      as participant_survey_id
    -  ,r.record             as record_id
    -  ,p.event_id
    -  ,e.descrip            as event_name
    -  ,r.first_submit_time
    -  ,r.completion_time
    -  
    -  -- ,p.*
    -  -- ,r.*
    -FROM redcapv3.redcap_surveys_participants     as p
    -  left  join redcapv3.redcap_surveys_response as r on p.participant_id = r.participant_id
    -  left  join redcapv3.redcap_events_metadata  as e on p.event_id       = e.event_id
    -where 
    -  p.survey_id = 444
    -  and
    -  p.event_id in (
    -    1001, -- start of the year
    -    1002, -- mid term
    -    1003  -- end of year
    -  )
    -

    Session Information

    @@ -369,27 +351,25 @@

    #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/Chicago -#> date 2020-03-13 +#> date 2020-04-19 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.1) -#> backports 1.1.5 2019-10-02 [2] CRAN (R 3.6.1) -#> callr 3.4.2 2020-02-12 [2] CRAN (R 3.6.2) +#> backports 1.1.6 2020-04-05 [2] CRAN (R 3.6.3) #> checkmate 2.0.0 2019-12-03 [2] local #> cli 2.0.2 2020-02-28 [2] CRAN (R 3.6.2) #> colorspace 1.4-1 2019-03-18 [2] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.1) #> curl 4.3 2019-12-02 [2] CRAN (R 3.6.1) #> desc 1.2.0 2018-05-01 [2] CRAN (R 3.6.1) -#> devtools 2.2.2 2020-02-17 [2] CRAN (R 3.6.2) #> digest 0.6.25 2020-02-23 [2] CRAN (R 3.6.2) #> dplyr 0.8.5 2020-03-07 [2] CRAN (R 3.6.3) #> ellipsis 0.3.0 2019-09-20 [2] CRAN (R 3.6.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.1) #> fansi 0.4.1 2020-01-08 [2] CRAN (R 3.6.1) -#> fs 1.3.2 2020-03-05 [2] CRAN (R 3.6.3) -#> glue 1.3.2 2020-03-12 [2] CRAN (R 3.6.3) +#> fs 1.4.1 2020-04-04 [2] CRAN (R 3.6.3) +#> glue 1.4.0 2020-04-03 [2] CRAN (R 3.6.3) #> hms 0.5.3 2020-01-08 [2] CRAN (R 3.6.1) #> htmltools 0.4.0 2019-10-04 [2] CRAN (R 3.6.1) #> httr 1.4.1 2019-08-05 [2] CRAN (R 3.6.1) @@ -401,19 +381,13 @@

    #> memoise 1.1.0 2017-04-21 [2] CRAN (R 3.6.1) #> munsell 0.5.0 2018-06-12 [2] CRAN (R 3.6.1) #> pillar 1.4.3 2019-12-20 [2] CRAN (R 3.6.1) -#> pkgbuild 1.0.6 2019-10-09 [2] CRAN (R 3.6.1) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 3.6.1) -#> pkgdown 1.4.1 2019-09-15 [2] CRAN (R 3.6.1) -#> pkgload 1.0.2 2018-10-29 [2] CRAN (R 3.6.1) -#> prettyunits 1.1.1 2020-01-24 [2] CRAN (R 3.6.2) -#> processx 3.4.2 2020-02-09 [2] CRAN (R 3.6.2) -#> ps 1.3.2 2020-02-13 [2] CRAN (R 3.6.2) +#> pkgdown 1.5.0 2020-03-25 [2] CRAN (R 3.6.3) #> purrr 0.3.3 2019-10-18 [2] CRAN (R 3.6.1) #> R6 2.4.1 2019-11-12 [2] CRAN (R 3.6.1) -#> Rcpp 1.0.3 2019-11-08 [2] CRAN (R 3.6.1) +#> Rcpp 1.0.4 2020-03-17 [2] CRAN (R 3.6.3) #> readr 1.3.1 2018-12-21 [2] CRAN (R 3.6.1) -#> REDCapR * 0.10.2.9005 2020-03-14 [1] local -#> remotes 2.1.1 2020-02-15 [2] CRAN (R 3.6.2) +#> REDCapR * 0.10.2.9006 2020-04-19 [1] local #> rlang 0.4.5 2020-03-01 [2] CRAN (R 3.6.2) #> rmarkdown 2.1 2020-01-20 [2] CRAN (R 3.6.2) #> rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.6.1) @@ -423,45 +397,32 @@

    #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 3.6.1) #> stringi 1.4.6 2020-02-17 [2] CRAN (R 3.6.2) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.1) -#> testthat 2.3.2 2020-03-02 [2] CRAN (R 3.6.3) -#> tibble 2.1.3 2019-06-06 [2] CRAN (R 3.6.1) +#> tibble 3.0.0 2020-03-30 [2] CRAN (R 3.6.3) #> tidyr 1.0.2 2020-01-24 [2] CRAN (R 3.6.2) #> tidyselect 1.0.0 2020-01-27 [2] CRAN (R 3.6.2) -#> usethis 1.5.1 2019-07-04 [2] CRAN (R 3.6.1) #> utf8 1.1.4 2018-05-24 [2] CRAN (R 3.6.1) #> vctrs 0.2.4 2020-03-10 [2] CRAN (R 3.6.3) #> viridisLite 0.3.0 2018-02-01 [2] CRAN (R 3.6.1) #> webshot 0.5.2 2019-11-22 [2] CRAN (R 3.6.1) #> withr 2.1.2 2018-03-15 [2] CRAN (R 3.6.1) #> xfun 0.12 2020-01-13 [2] CRAN (R 3.6.1) -#> xml2 1.2.5 2020-03-11 [2] CRAN (R 3.6.3) +#> xml2 1.3.0 2020-04-01 [2] CRAN (R 3.6.3) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 3.6.2) #> -#> [1] /tmp/Rtmp830zQN/temp_libpath1f7158fa5947 +#> [1] /tmp/Rtmp5avAp4/temp_libpath4e6a183ad817 #> [2] /home/wibeasley/R/x86_64-pc-linux-gnu-library/3.6 #> [3] /usr/local/lib/R/site-library #> [4] /usr/lib/R/site-library #> [5] /usr/lib/R/library -

    Report rendered by wibeasley at 2020-03-13, 20:40 -0500 in 4 seconds.

    +

    Report rendered by wibeasley at 2020-04-19, 13:32 -0500 in 7 seconds.

    - @@ -472,7 +433,7 @@

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/articles/index.html b/docs/articles/index.html index 97bec46b..87448b36 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,15 +46,14 @@ - + - - + @@ -68,7 +71,7 @@ - +
    @@ -97,26 +100,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -124,7 +109,7 @@
  • @@ -172,7 +161,7 @@

    Getting Started

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/authors.html b/docs/authors.html index 3364d87c..32ba9174 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,15 +46,14 @@ - + - - + @@ -68,7 +71,7 @@ - +
    @@ -97,26 +100,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -124,7 +109,7 @@
  • @@ -202,7 +191,7 @@

    Authors

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 00000000..5a859415 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 00000000..1cdd573b --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.json b/docs/docsearch.json index 3df6fce9..cdc94736 100644 --- a/docs/docsearch.json +++ b/docs/docsearch.json @@ -74,7 +74,7 @@ "selector": ".contents h2, .contents h3", "default_value": "Context" }, - "text": ".contents p, .contents li, .tempate-article .contents .pre" + "text": ".contents p, .contents li" } }, "selectors_exclude": [ diff --git a/docs/favicon-16x16.png b/docs/favicon-16x16.png new file mode 100644 index 00000000..20d59577 Binary files /dev/null and b/docs/favicon-16x16.png differ diff --git a/docs/favicon-32x32.png b/docs/favicon-32x32.png new file mode 100644 index 00000000..02f147c0 Binary files /dev/null and b/docs/favicon-32x32.png differ diff --git a/docs/favicon.ico b/docs/favicon.ico new file mode 100644 index 00000000..d334a299 Binary files /dev/null and b/docs/favicon.ico differ diff --git a/docs/index.html b/docs/index.html index 5eddc9a1..28ed8634 100644 --- a/docs/index.html +++ b/docs/index.html @@ -12,11 +12,12 @@ - - - - - + + + + + + - - + - +
    -
    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/collapse_vector.html b/docs/reference/collapse_vector.html index b6814cef..4938672f 100644 --- a/docs/reference/collapse_vector.html +++ b/docs/reference/collapse_vector.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -54,8 +58,7 @@ In the R world, it's easier to keep these values as separate elements in a vector. This functions squashes them together in a single character element (presumably right before the return value is passed to the API)" /> - - + @@ -73,7 +76,7 @@ - +
    @@ -102,26 +105,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -129,7 +114,7 @@
  • #> [1] ""
    REDCapR:::collapse_vector(elements=letters, collapsed=NULL)
    #> [1] "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"
    REDCapR:::collapse_vector(elements=NULL, collapsed="4,5,6")
    #> [1] "4,5,6"
    - @@ -211,7 +190,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/constant.html b/docs/reference/constant.html index 9cb46b71..4682ba7d 100644 --- a/docs/reference/constant.html +++ b/docs/reference/constant.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/create_batch_glossary.html b/docs/reference/create_batch_glossary.html index a170181f..ed2b7a9b 100644 --- a/docs/reference/create_batch_glossary.html +++ b/docs/reference/create_batch_glossary.html @@ -18,23 +18,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -43,7 +47,7 @@ - + @@ -56,8 +60,7 @@ multiple, smaller REDCap calls. The goal is to (1) reduce the chance of time-outs, and (2) introduce little breaks between batches so that the server isn't continually tied up." /> - - + @@ -75,7 +78,7 @@ - +
    @@ -104,26 +107,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -131,7 +116,7 @@
  • -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 95576147..b561a209 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,15 +46,14 @@ - + - - + @@ -68,7 +71,7 @@ - +
    @@ -97,26 +100,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -124,7 +109,7 @@
  • - @@ -383,7 +394,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/kernel_api.html b/docs/reference/kernel_api.html index 58d2d5b8..4f195924 100644 --- a/docs/reference/kernel_api.html +++ b/docs/reference/kernel_api.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -51,8 +55,7 @@ - - + @@ -70,7 +73,7 @@ - +
    @@ -99,26 +102,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -126,7 +111,7 @@
  • #> Response [https://bbmc.ouhsc.edu/redcap/api/] -#> Date: 2020-02-18 16:35 +#> Date: 2020-04-19 18:31 #> Status: 200 #> Content-Type: text/csv; charset=utf-8 #> Size: 557 B @@ -312,15 +297,10 @@

    Examp #> [1] 0 #>

    - @@ -331,7 +311,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/metadata_utilities.html b/docs/reference/metadata_utilities.html index 235650b2..d0081f5a 100644 --- a/docs/reference/metadata_utilities.html +++ b/docs/reference/metadata_utilities.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -51,8 +55,7 @@ - - + @@ -70,7 +73,7 @@ - +
    @@ -99,26 +102,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -126,7 +111,7 @@
  • #> id label +REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_1)
    #> id label #> 1 1 American Indian/Alaska Native #> 2 2 Asian #> 3 3 Native Hawaiian or Other Pacific Islander @@ -234,7 +219,7 @@

    Examp #> 5 5 White #> 6 6 Unknown / Not Reported

    # This function is designed specifically for the checkbox values. -REDCapR::checkbox_choices(select_choices=choices_1)
    #> id label +REDCapR::checkbox_choices(select_choices=choices_1)
    #> id label #> 1 1 American Indian/Alaska Native #> 2 2 Asian #> 3 3 Native Hawaiian or Other Pacific Islander @@ -248,13 +233,13 @@

    Examp ds_metadata <- redcap_metadata_read(redcap_uri=uri, token=token)$data choices_2 <- ds_metadata[ds_metadata$field_name=="race", "select_choices_or_calculations"] -REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_2) +REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_2) } path_3 <- system.file(package="REDCapR", "test-data/project-simple/simple-metadata.csv") ds_metadata_3 <- read.csv(path_3, stringsAsFactors=FALSE) choices_3 <- ds_metadata_3[ds_metadata_3$field_name=="race", "select_choices_or_calculations"] -REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_3)

    #> id label +REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_3)
    #> id label #> 1 1 American Indian/Alaska Native #> 2 2 Asian #> 3 3 Native Hawaiian or Other Pacific Islander @@ -262,18 +247,10 @@

    Examp #> 5 5 White #> 6 6 Unknown / Not Reported

    - @@ -284,7 +261,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_column_sanitize.html b/docs/reference/redcap_column_sanitize.html index f295d152..8001f4d5 100644 --- a/docs/reference/redcap_column_sanitize.html +++ b/docs/reference/redcap_column_sanitize.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -51,8 +55,7 @@ - - + @@ -70,7 +73,7 @@ - +
    @@ -99,26 +102,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -126,7 +111,7 @@
  • #> id names +REDCapR::redcap_column_sanitize(dirty)
    #> id names #> 1 1 Ekstrom #> 2 2 Joreskog #> 3 3 bisschen Zurcher
    - @@ -239,7 +217,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_download_file_oneshot.html b/docs/reference/redcap_download_file_oneshot.html index f06e2360..f8776549 100644 --- a/docs/reference/redcap_download_file_oneshot.html +++ b/docs/reference/redcap_download_file_oneshot.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -319,7 +311,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_download_instrument.html b/docs/reference/redcap_download_instrument.html index 2e041fd2..2b854bc8 100644 --- a/docs/reference/redcap_download_instrument.html +++ b/docs/reference/redcap_download_instrument.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -316,7 +293,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_metadata_read.html b/docs/reference/redcap_metadata_read.html index 15d9406a..d03c3248 100644 --- a/docs/reference/redcap_metadata_read.html +++ b/docs/reference/redcap_metadata_read.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -52,8 +56,7 @@ - - + @@ -71,7 +74,7 @@ - +
    @@ -100,26 +103,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -127,7 +112,7 @@
  • - @@ -287,7 +264,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_metadata_write.html b/docs/reference/redcap_metadata_write.html index 638098b6..50dc1b30 100644 --- a/docs/reference/redcap_metadata_write.html +++ b/docs/reference/redcap_metadata_write.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -52,8 +56,7 @@ - - + @@ -71,7 +74,7 @@ - +
    @@ -100,26 +103,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -127,7 +112,7 @@
  • - @@ -273,7 +251,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_next_free_record_name.html b/docs/reference/redcap_next_free_record_name.html index 34a2742e..5d146e09 100644 --- a/docs/reference/redcap_next_free_record_name.html +++ b/docs/reference/redcap_next_free_record_name.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • #> The next free record name in REDCap was successfully determined in 0.2 seconds. The http status code was 200. Is is 6.
    #> [1] "6"
    - @@ -255,7 +234,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_project.html b/docs/reference/redcap_project.html index b11cb20b..1d59fbe5 100644 --- a/docs/reference/redcap_project.html +++ b/docs/reference/redcap_project.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -53,8 +57,7 @@ Once some values are set that are specific to a REDCap project (such as the URI and token), later calls are less verbose (such as reading and writing data)." /> - - + @@ -72,7 +75,7 @@ - +
    @@ -101,26 +104,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -128,7 +113,7 @@
  • - @@ -262,7 +243,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_read.html b/docs/reference/redcap_read.html index 99dcf3bd..5d10d3c5 100644 --- a/docs/reference/redcap_read.html +++ b/docs/reference/redcap_read.html @@ -18,23 +18,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -43,7 +47,7 @@ - + @@ -57,8 +61,7 @@ (among other objects) a single base::data.frame(). This function can be more appropriate than redcap_read_oneshot() when returning large datasets that could tie up the server." /> - - + @@ -76,7 +79,7 @@ - +
    @@ -105,26 +108,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -132,7 +117,7 @@
  • - @@ -446,7 +423,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_read_oneshot.html b/docs/reference/redcap_read_oneshot.html index 27a79d1c..4506be18 100644 --- a/docs/reference/redcap_read_oneshot.html +++ b/docs/reference/redcap_read_oneshot.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -409,7 +386,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_read_oneshot_eav.html b/docs/reference/redcap_read_oneshot_eav.html index d17dcf8c..80b46918 100644 --- a/docs/reference/redcap_read_oneshot_eav.html +++ b/docs/reference/redcap_read_oneshot_eav.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -51,8 +55,7 @@ - - + @@ -70,7 +73,7 @@ - +
    @@ -99,26 +102,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -126,7 +111,7 @@
  • - @@ -363,7 +340,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_survey_link_export_oneshot.html b/docs/reference/redcap_survey_link_export_oneshot.html index 05148c80..728d1100 100644 --- a/docs/reference/redcap_survey_link_export_oneshot.html +++ b/docs/reference/redcap_survey_link_export_oneshot.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -283,7 +260,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_upload_file_oneshot.html b/docs/reference/redcap_upload_file_oneshot.html index 56fcc80b..8e6b6ebc 100644 --- a/docs/reference/redcap_upload_file_oneshot.html +++ b/docs/reference/redcap_upload_file_oneshot.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -307,7 +284,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_users_export.html b/docs/reference/redcap_users_export.html index bf1520d2..0275268a 100644 --- a/docs/reference/redcap_users_export.html +++ b/docs/reference/redcap_users_export.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -242,7 +222,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_variables.html b/docs/reference/redcap_variables.html index 91da6971..94c9b1d9 100644 --- a/docs/reference/redcap_variables.html +++ b/docs/reference/redcap_variables.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -51,8 +55,7 @@ - - + @@ -70,7 +73,7 @@ - +
    @@ -99,26 +102,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -126,7 +111,7 @@
  • - @@ -253,7 +230,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_version.html b/docs/reference/redcap_version.html index 8c370e06..4aea7636 100644 --- a/docs/reference/redcap_version.html +++ b/docs/reference/redcap_version.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • #> The REDCap version was successfully determined in 0.2 seconds. The http status code was 200. Is is 9.0.0.
    #> [1] ‘9.0.0’
    - @@ -222,7 +202,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_write.html b/docs/reference/redcap_write.html index 979b7212..9a452dcb 100644 --- a/docs/reference/redcap_write.html +++ b/docs/reference/redcap_write.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -309,7 +286,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/redcap_write_oneshot.html b/docs/reference/redcap_write_oneshot.html index 6bf5503f..4f96faa1 100644 --- a/docs/reference/redcap_write_oneshot.html +++ b/docs/reference/redcap_write_oneshot.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -50,8 +54,7 @@ - - + @@ -69,7 +72,7 @@ - +
    @@ -98,26 +101,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -125,7 +110,7 @@
  • - @@ -283,7 +260,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/replace_nas_with_explicit.html b/docs/reference/replace_nas_with_explicit.html index b1fbc08e..68fd9dab 100644 --- a/docs/reference/replace_nas_with_explicit.html +++ b/docs/reference/replace_nas_with_explicit.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -53,8 +57,7 @@ This explicit assignment can reduce the chances that missing values are inadvertently ignored. It also allows the presence of a missing to become a predictor in models." /> - - + @@ -72,7 +75,7 @@ - +
    @@ -101,26 +104,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -128,7 +113,7 @@
  • - @@ -231,7 +209,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/retrieve_credential.html b/docs/reference/retrieve_credential.html index 5b6abb9a..62495a60 100644 --- a/docs/reference/retrieve_credential.html +++ b/docs/reference/retrieve_credential.html @@ -18,23 +18,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -43,7 +47,7 @@ - + @@ -53,8 +57,7 @@ database or file — retrieve_credential" /> - - + @@ -72,7 +75,7 @@ - +
    @@ -101,26 +104,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -128,7 +113,7 @@
  • - @@ -304,7 +281,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/sanitize_token.html b/docs/reference/sanitize_token.html index cab9374f..c3744d7b 100644 --- a/docs/reference/sanitize_token.html +++ b/docs/reference/sanitize_token.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -42,7 +46,7 @@ - + @@ -52,8 +56,7 @@ - - + @@ -71,7 +74,7 @@ - +
    @@ -100,26 +103,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -127,7 +112,7 @@
  • #> [1] "12345678901234567890123456ABCDEF"
    REDCapR::sanitize_token(secret_token_2)
    #> [1] "12345678901234567890123456ABCDEF"
    - @@ -207,7 +185,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/docs/reference/validate.html b/docs/reference/validate.html index bc972298..98e30b5b 100644 --- a/docs/reference/validate.html +++ b/docs/reference/validate.html @@ -18,23 +18,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -43,7 +47,7 @@ - + @@ -53,8 +57,7 @@ writing to a REDCap project — validate" /> - - + @@ -72,7 +75,7 @@ - +
    @@ -101,26 +104,8 @@
  • Reference
  • -
  • + Articles
  • Changelog @@ -128,7 +113,7 @@
  • #> # A tibble: 2 x 4 +REDCapR::validate_for_write(d = d)
    #> # A tibble: 2 x 4 #> field_name field_index concern suggestion #> <chr> <int> <chr> <chr> #> 1 flag_logical 2 The REDCap API does not … Convert the variable with … #> 2 flag_Upperc… 3 A REDCap project does no… Change the uppercase lette…
    - @@ -277,7 +254,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.0.

    diff --git a/inst/test-data/problematic-dictionary/problematic-dictionary.csv b/inst/test-data/problematic-dictionary/problematic-dictionary.csv index fbc1c4f5..0d05e936 100644 --- a/inst/test-data/problematic-dictionary/problematic-dictionary.csv +++ b/inst/test-data/problematic-dictionary/problematic-dictionary.csv @@ -2,3 +2,6 @@ record_id,form_1,,text,"Record ID",,,,,,,,,,,,, v1,form_1,,dropdown,"Is the laser mounted on the shark?�?�","0, No | 1, Yes | 3, I should find out",,,,,,,,,,,, curly_quote_single,form_1,,radio,My child doesn’t like candy,"0, (0) Never or Almost Never | 1, (1) Sometimes | 2, (2) Often",,,,,,,,,,,, +curly_quote_double_left,form_1,,radio,Maybe I don't “look the part","0, Bennett | 1, Brauer",,,,,,,,,,,,https://github.com/OuhscBbmc/REDCapR/issues/290 +curly_quote_double_right,form_1,,radio,Maybe I don't "look comfortable on camera”,"0, Bennett | 1, Brauer",,,,,,,,,,,,https://github.com/OuhscBbmc/REDCapR/issues/290 +long_dash,form_1,,radio,Maybe I don't "wear the latest clothes" −or even ones that don't "reek","0, Bennett | 1, Brauer",,,,,,,,,,,,https://github.com/OuhscBbmc/REDCapR/issues/290 diff --git a/inst/test-data/project-color-boxes/Readme.md b/inst/test-data/project-color-boxes/Readme.md index cf252fcb..ffbcb46d 100644 --- a/inst/test-data/project-color-boxes/Readme.md +++ b/inst/test-data/project-color-boxes/Readme.md @@ -35,7 +35,7 @@ Here's some (slightly modified) code that Benjamin wrote for Issue #51: > post_result_all <- httr::POST(url=url, body=list(token=token, content='record', format='csv', rawOrLabel='label', fields='id, color')) > (csv_all <- as.character(post_result_all)) [1] "id,color___r,color___g,color___b,color___p\n\"1\",\"Red\",\"\",\"\",\"\"\n\"2\",\"\",\"\",\"Blue\",\"\"\n\"3\",\"\",\"Green\",\"Blue\",\"\"\n\"4\",\"\",\"\",\"\",\"\"\n" -> (ds_all <- read.csv(textConnection(csv_all), stringsAsFactors=F)) +> (ds_all <- read.csv(textConnection(csv_all), stringsAsFactors=FALSE)) id color___r color___g color___b color___p 1 1 Red NA 2 2 Blue NA @@ -45,7 +45,7 @@ Here's some (slightly modified) code that Benjamin wrote for Issue #51: > post_result_some <- httr::POST(url=url, body=list(token=token, content='record', format='csv', rawOrLabel='label', fields='id, color', records='2,3,4')) > (csv_some <- as.character(post_result_some)) [1] "id,color___r,color___g,color___b,color___p\n\"2\",\"\",\"\",\"Blue\",\"\"\n\"3\",\"\",\"Green\",\"Blue\",\"\"\n\"4\",\"\",\"\",\"\",\"\"\n" -> (ds_some <- read.csv(textConnection(csv_some), stringsAsFactors=F)) +> (ds_some <- read.csv(textConnection(csv_some), stringsAsFactors=FALSE)) id color___r color___g color___b color___p 1 2 NA Blue NA 2 3 NA Green Blue NA diff --git a/man/redcap_download_file_oneshot.Rd b/man/redcap_download_file_oneshot.Rd index b5e6232b..c3a25d83 100644 --- a/man/redcap_download_file_oneshot.Rd +++ b/man/redcap_download_file_oneshot.Rd @@ -13,6 +13,8 @@ redcap_download_file_oneshot( record, field, event = "", + repeat_instrument = NULL, + repeat_instance = NULL, verbose = TRUE, config_options = NULL ) @@ -42,6 +44,15 @@ Required} \item{event}{The name of the event where the file is saved in REDCap. Optional} +\item{repeat_instrument}{The name of the instrument that is repeating +for a given event. +Optional} + +\item{repeat_instance}{(only for projects with repeating instruments/events) +The repeat instance number of the repeating event (if longitudinal) or the +repeating instrument (if classic or longitudinal). Default value is '1'. +Optional} + \item{verbose}{A boolean value indicating if \code{message}s should be printed to the R console during the operation. Optional.} diff --git a/playgrounds/HttrPlayground.R b/playgrounds/HttrPlayground.R index 32b68119..799cb596 100644 --- a/playgrounds/HttrPlayground.R +++ b/playgrounds/HttrPlayground.R @@ -17,7 +17,7 @@ events_collapsed <- NULL config_options <- list(cainfo = system.file("cacert.pem", package="openssl")) # config_options <- RCurl::curlOptions(ssl.verifypeer = FALSE) -config_options <- httr::config(ssl_verifypeer=F) +config_options <- httr::config(ssl_verifypeer=FALSE) # config_options <- list() post_body <- list( @@ -46,14 +46,14 @@ raw_text <- httr::content(result, "text") result <- httr::POST( url = "http://httpbin.org/post", - body = "A simple text string", + body = "A simple text string", config = httr::config(ssl_verifypeer=FALSE) ) httr::content(result, "text") ds <- utils::read.csv(text=raw_text, stringsAsFactors=FALSE) #Convert the raw text to a dataset. -# +# # raw_text2 <- RCurl::postForm( # uri = redcap_uri # , token = token @@ -70,32 +70,32 @@ ds <- utils::read.csv(text=raw_text, stringsAsFactors=FALSE) #Convert the raw te # result <- redcap_read_oneshot(redcap_uri="https://bbmc.ouhsc.edu/redcap/api/", token = "9A81268476645C4E5F03428B8AC3AA7B") # dput(result$data) -dsToWrite <- structure(list(record_id = 1:5, name_first = c("Nutmeg", "Tumtum", - "Marcus", "Trudy", "John Lee"), name_last = c("Nutmouse", "Nutmouse", - "Wood", "DAG", "Walker"), address = c("14 Rose Cottage St.\nKenning UK, 323232", - "14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402", +dsToWrite <- structure(list(record_id = 1:5, name_first = c("Nutmeg", "Tumtum", + "Marcus", "Trudy", "John Lee"), name_last = c("Nutmouse", "Nutmouse", + "Wood", "DAG", "Walker"), address = c("14 Rose Cottage St.\nKenning UK, 323232", + "14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402", "342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115" - ), telephone = c("(432) 456-4848", "(234) 234-2343", "(433) 435-9865", - "(987) 654-3210", "(333) 333-4444"), email = c("nutty@mouse.com", + ), telephone = c("(432) 456-4848", "(234) 234-2343", "(433) 435-9865", + "(987) 654-3210", "(333) 333-4444"), email = c("nutty@mouse.com", "tummy@mouse.comm", "mw@mwood.net", "peroxide@blonde.com", "left@hippocket.com" - ), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02", - "1955-04-15"), age = c(10L, 10L, 79L, 61L, 58L), ethnicity = c(1L, - 1L, 0L, 1L, 1L), race = c(2L, 6L, 4L, 4L, 4L), sex = c(0L, 1L, - 1L, 0L, 1L), height = c(5, 6, 180, 165, 193.04), weight = c(1L, - 1L, 80L, 54L, 104L), bmi = c(400, 277.8, 24.7, 19.8, 27.9), comments = c("Character in a book, with some guessing", - "A mouse character from a good book", "completely made up", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", + ), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02", + "1955-04-15"), age = c(10L, 10L, 79L, 61L, 58L), ethnicity = c(1L, + 1L, 0L, 1L, 1L), race = c(2L, 6L, 4L, 4L, 4L), sex = c(0L, 1L, + 1L, 0L, 1L), height = c(5, 6, 180, 165, 193.04), weight = c(1L, + 1L, 80L, 54L, 104L), bmi = c(400, 277.8, 24.7, 19.8, 27.9), comments = c("Character in a book, with some guessing", + "A mouse character from a good book", "completely made up", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache" - ), demographics_complete = c(2L, 2L, 2L, 2L, 2L)), .Names = c("record_id", - "name_first", "name_last", "address", "telephone", "email", "dob", - "age", "ethnicity", "race", "sex", "height", "weight", "bmi", - "comments", "demographics_complete"), class = "data.frame", row.names = c(NA, + ), demographics_complete = c(2L, 2L, 2L, 2L, 2L)), .Names = c("record_id", + "name_first", "name_last", "address", "telephone", "email", "dob", + "age", "ethnicity", "race", "sex", "height", "weight", "bmi", + "comments", "demographics_complete"), class = "data.frame", row.names = c(NA, -5L)) dsToWrite$age <- NULL; dsToWrite$bmi <- NULL #Drop the calculated fields # dsToWrite <- dsToWrite[1:3, ] # result <- REDCapR::redcap_write_oneshot(ds=dsToWrite, redcap_uri="https://bbmc.ouhsc.edu/redcap/api/", token = "9A81268476645C4E5F03428B8AC3AA7B") con <- base::textConnection(object='csvElements', open='w', local=TRUE) -utils::write.csv(dsToWrite, con, row.names = FALSE, na="") +utils::write.csv(dsToWrite, con, row.names = FALSE, na="") close(con) csv <- paste(csvElements, collapse="\n") @@ -111,12 +111,12 @@ post_body <- list( exportDataAccessGroups = export_data_access_groups_string, records = records_collapsed, fields = fields_collapsed, - + #These next values separate the import from the export API call data = csv, overwriteBehavior = 'overwrite', #overwriteBehavior: *normal* - blank/empty values will be ignored [default]; *overwrite* - blank/empty values are valid and will overwrite data returnContent = 'ids', - returnFormat = 'csv' + returnFormat = 'csv' ) result <- httr::POST( @@ -131,11 +131,11 @@ status_message <- result$headers$statusmessage return_content <- httr::content(result, type="text") # returnContent <- RCurl::postForm( -# uri = redcap_uri, +# uri = redcap_uri, # token = token, # content = 'record', -# format = 'csv', -# type = 'flat', +# format = 'csv', +# type = 'flat', # returnContent = "ids", # overwriteBehavior = 'overwrite', #overwriteBehavior: *normal* - blank/empty values will be ignored [default]; *overwrite* - blank/empty values are valid and will overwrite data # data = csv, diff --git a/playgrounds/MetadataPlayground.R b/playgrounds/MetadataPlayground.R index 5ab6483f..0db781ac 100644 --- a/playgrounds/MetadataPlayground.R +++ b/playgrounds/MetadataPlayground.R @@ -23,7 +23,7 @@ pattern_checkboxes <- "(?<=\\A| \\| )(?\\d{1,}), (?