Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove more instances of .data #458

Merged
merged 6 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ This will help extract forms from longitudinal & repeating projects.
* `redcap_file_upload_oneshot()` to `redcap_file_upload_opneshot()`
* `redcap_download_instrument()` to `redcap_instrument_download()`

* `redcap_dag_read()` has new `data_access_group_id` field (introduced maybe in [13.1.0](https://community.projectredcap.org/articles/13/index.html)) (#459)
* `redcap_users_export()` has new `mycap_participants` field (introduced maybe in [13.0.0](https://community.projectredcap.org/articles/13/index.html)) (#459)

Version 1.1.0 (released 2022-08-10)
==========================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ structure(list(username = c("unittestphifree", "wbeasleya"),
TRUE), mobile_app_download_data = c(FALSE, TRUE), record_create = c(FALSE,
TRUE), record_rename = c(FALSE, FALSE), record_delete = c(FALSE,
FALSE), lock_records_all_forms = c(FALSE, FALSE), lock_records = c(FALSE,
FALSE), lock_records_customization = c(FALSE, FALSE), forms_export = c("demographics:1",
"demographics:1")), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))
FALSE), lock_records_customization = c(FALSE, FALSE), mycap_participants = c(0,
0), forms_export = c("demographics:1", "demographics:1")), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ structure(list(username = c("unittestphifree", "wbeasleya"),
FALSE), mobile_app_download_data = c(FALSE, FALSE), record_create = c(TRUE,
TRUE), record_rename = c(FALSE, FALSE), record_delete = c(FALSE,
FALSE), lock_records_all_forms = c(FALSE, FALSE), lock_records = c(FALSE,
FALSE), lock_records_customization = c(FALSE, FALSE), forms_export = c("demographics:1,health:1,race_and_ethnicity:1",
FALSE), lock_records_customization = c(FALSE, FALSE), mycap_participants = c(0,
0), forms_export = c("demographics:1,health:1,race_and_ethnicity:1",
"demographics:1,health:1,race_and_ethnicity:1")), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))
14 changes: 7 additions & 7 deletions playgrounds/eav-playground-2.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ds_eav_possible <-
# ds_form_pt <-
# ds_metadata %>%
# dplyr::filter(.data$field_type == "complete") %>%
# dplyr::select(.data$field_name, .data$form_name) %>%
# dplyr::select("field_name", "form_name") %>%
# dplyr::inner_join(ds_eav, by = "field_name") %>%
# dplyr::mutate(
# .default_check = dplyr::i
Expand All @@ -107,10 +107,10 @@ ds_eav_2 <-
value = dplyr::if_else(.data$checkbox, as.character(!is.na(.data$value)), .data$value),
) %>%
dplyr::right_join(ds_eav_possible, by = c("record", "event_id", "field_name")) %>%
dplyr::select(-.data$field_type, -.data$field_name_base, -.data$checkbox) %>%
dplyr::select(-"field_type", -"field_name_base", -"checkbox") %>%
dplyr::left_join(
ds_metadata %>%
dplyr::select(.data$field_name, .data$field_name_base, .data$field_type),
dplyr::select("field_name", "field_name_base", "field_type"),
by = "field_name"
) %>%
dplyr::mutate(
Expand All @@ -120,7 +120,7 @@ ds_eav_2 <-

ds <-
ds_eav_2 %>%
dplyr::select(-.data$field_type, -.data$field_name_base) %>%
dplyr::select(-"field_type", -"field_name_base") %>%
# dplyr::slice(1:46) %>%
# dplyr::group_by(record, redcap_repeat_instrument, redcap_repeat_instance, event_id, field_name) %>%
# dplyr::summarise(n = dplyr::n(), .groups = "drop") %>%
Expand All @@ -130,8 +130,8 @@ ds <-
# tidyr::drop_na(event_id) %>% # TODO: need a good fix for repeats
tidyr::pivot_wider( # Everything else is considered an ID column
id_cols = !!.fields_plumbing,
names_from = .data$field_name,
values_from = .data$value
names_from = "field_name",
values_from = "value"
) %>%
dplyr::select(!!.fields_to_return)
# dplyr::select(.data = ., !!intersect(variables_to_keep, colnames(.)))
Expand All @@ -144,7 +144,7 @@ ds[[.record_id_name]] <- NULL
ds <-
ds %>%
dplyr::rename(
!!.record_id_name := .data$record
!!.record_id_name := "record"
) %>%
readr::type_convert(col_types)# |>
# View()
Expand Down
15 changes: 10 additions & 5 deletions tests/testthat/test-dag-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ test_that("smoke", {
test_that("dag-default", {
testthat::skip_on_cran()
expected_data <-
structure(
list(data_access_group_name = c("dag_1", "dag_2"),
unique_group_name = c("dag_1", "dag_2")), row.names = c(NA,
-2L), spec = structure(list(cols = list(data_access_group_name = structure(list(), class = c("collector_character",
structure(list(data_access_group_name = c("dag_1", "dag_2"),
unique_group_name = c("dag_1", "dag_2"), data_access_group_id = c(36,
37)), row.names = c(NA, -2L), spec = structure(list(cols = list(
data_access_group_name = structure(list(), class = c("collector_character",
"collector")), unique_group_name = structure(list(), class = c("collector_character",
"collector")), data_access_group_id = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame")
)
# dput(actual$data)
actual <-
redcap_dag_read(
redcap_uri = credential_1$redcap_uri,
Expand All @@ -45,13 +47,16 @@ test_that("dag-default", {
testthat::skip_on_cran()
expected_data <-
structure(
list(data_access_group_name = character(0), unique_group_name = character(0)), row.names = integer(0), spec = structure(list(
list(data_access_group_name = character(0), unique_group_name = character(0),
data_access_group_id = character(0)), row.names = integer(0), spec = structure(list(
cols = list(data_access_group_name = structure(list(), class = c("collector_character",
"collector")), unique_group_name = structure(list(), class = c("collector_character",
"collector")), data_access_group_id = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame")
)
# dput(actual$data)

actual <-
redcap_dag_read(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ test_that("version-successful", {
verbose = FALSE
)

expected <- package_version("12.5.5")
expected <- package_version("13.1.0")
version_good <- (expected <= actual)
expect_true(version_good)
})

test_that("version-unuccessful-bad-token", {
test_that("version-unsuccessful-bad-token", {
testthat::skip_on_cran()
actual <-
redcap_version(
Expand Down