Skip to content

Commit

Permalink
Merge pull request #251 from OuhscBbmc/dev
Browse files Browse the repository at this point in the history
fixes breaking changes in tidyr 1.0.0
  • Loading branch information
wibeasley authored Sep 21, 2019
2 parents 23bf0c6 + 6d76e90 commit e641641
Show file tree
Hide file tree
Showing 64 changed files with 2,294 additions and 1,732 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ README.html$

documentation-peek.pdf
documentation-for-developers/
pkgdown/
playgrounds/
utility/
^\.travis\.yml$
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Version 0.10 (to be released)
* When the `verbose` parameter is NULL, then the value from getOption("verbose") is used. (#215)
* `guess_max` parameter provided in `redcap_read()` (no longer just `redcap_read_oneshot()`). Suggested by @isaactpetersen in #245.
* Documentation website constructed with pkgdown (#224).
* `redcap_variables()` now throws an error when passed a bad URI (commit e542155639bbb7).

### Modified Internals
* All interaction with the REDCap server goes through the new `kernal_api()` function, which uses the 'httr' and 'curl' packages underneath. Until now, each function called those packages directly. (#213)
Expand Down
26 changes: 13 additions & 13 deletions R/redcap-read-oneshot-eav.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#' token <- "9A81268476645C4E5F03428B8AC3AA7B"
#'
#' #Return all records and all variables.
#' ds <- REDCapR::redcap_read_oneshot_eav(redcap_uri=uri, token=token)$data
#' ds <- REDCapR:::redcap_read_oneshot_eav(redcap_uri=uri, token=token)$data
#'
#' #Return only records with IDs of 1 and 3
#' desired_records_v1 <- c(1, 3)
Expand Down Expand Up @@ -171,15 +171,15 @@ redcap_read_oneshot_eav <- function(

ds_metadata_expanded <-
ds_metadata %>%
dplyr::select_("field_name", "select_choices_or_calculations", "field_type") %>%
dplyr::select(.data$field_name, .data$select_choices_or_calculations, .data$field_type) %>%
dplyr::mutate(
is_checkbox = (.data$field_type=="checkbox"),
ids = dplyr::if_else(.data$is_checkbox, .data$select_choices_or_calculations, "1"),
ids = gsub("(\\d+),.+?(\\||$)", "\\1", .data$ids),
ids = strsplit(.data$ids, " ")
) %>%
dplyr::select_("-select_choices_or_calculations", "-field_type") %>%
tidyr::unnest_("ids") %>%
dplyr::select(-.data$select_choices_or_calculations, -.data$field_type) %>%
tidyr::unnest(.data$ids) %>%
dplyr::transmute(
.data$is_checkbox,
field_name = dplyr::if_else(.data$is_checkbox, paste0(.data$field_name, "___", .data$ids), .data$field_name)
Expand All @@ -188,23 +188,23 @@ redcap_read_oneshot_eav <- function(

distinct_checkboxes <-
ds_metadata_expanded %>%
dplyr::filter_("is_checkbox") %>%
dplyr::filter(.data$is_checkbox) %>%
dplyr::pull(.data$field_name)

ds_possible_checkbox_rows <-
tidyr::crossing(
field_name = distinct_checkboxes,
record = dplyr::distinct(ds_eav, .data$record),
record = unique(ds_eav$record),
field_type = "checkbox",
event_id = dplyr::distinct(ds_eav, .data$event_id)
event_id = unique(ds_eav$event_id)
)

variables_to_keep <-
ds_metadata_expanded %>%
dplyr::select(.data$field_name) %>%
dplyr::union(
ds_variable %>%
dplyr::select_("field_name" = "export_field_name") %>%
dplyr::select(field_name = .data$export_field_name) %>%
dplyr::filter(grepl("^\\w+?_complete$", .data$field_name))
) %>%
dplyr::pull(.data$field_name) %>%
Expand All @@ -214,7 +214,7 @@ redcap_read_oneshot_eav <- function(
ds_eav %>%
dplyr::left_join(
ds_metadata %>%
dplyr::select_("field_name", "field_type"),
dplyr::select(.data$field_name, .data$field_type),
by = "field_name"
) %>%
dplyr::mutate(
Expand All @@ -228,11 +228,11 @@ redcap_read_oneshot_eav <- function(
. <- NULL # For the sake of avoiding an R CMD check note.
ds <-
ds_eav_2 %>%
dplyr::select_("-field_type") %>%
# dplyr::select_("-redcap_repeat_instance") %>% # TODO: need a good fix for repeats
dplyr::select(-.data$field_type) %>%
# dplyr::select(-.data$redcap_repeat_instance) %>% # TODO: need a good fix for repeats
# tidyr::drop_na(event_id) %>% # TODO: need a good fix for repeats
tidyr::spread_(key="field_name", value="value") %>%
dplyr::select_(.data=., .dots=intersect(variables_to_keep, colnames(.)))
tidyr::spread(key=.data$field_name, value=.data$value) %>%
dplyr::select(.data=., !! intersect(variables_to_keep, colnames(.)))

ds_2 <-
ds %>%
Expand Down
6 changes: 3 additions & 3 deletions R/redcap-users-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ redcap_users_export <- function( redcap_uri, token, verbose=TRUE, config_options

ds_user <-
ds_combined %>%
dplyr::select_("-forms")
dplyr::select(-.data$forms)

ds_user_form <-
ds_combined %>%
dplyr::select_("username", "forms") %>%
dplyr::select(.data$username, .data$forms) %>%
tidyr::separate_rows(.data$forms, sep=",") %>%
# tidyr::separate_(
# col = "form",
Expand All @@ -116,7 +116,7 @@ redcap_users_export <- function( redcap_uri, token, verbose=TRUE, config_options
# )

) %>%
dplyr::select_("-forms")
dplyr::select(-.data$forms)
},
silent = TRUE #Don't print the warning in the try block. Print it below, where it's under the control of the caller.
)
Expand Down
197 changes: 197 additions & 0 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e641641

Please sign in to comment.