From 6f64d40e86d1e6384f4b0073751a684d732f4580 Mon Sep 17 00:00:00 2001 From: Matt Roumaya Date: Sat, 4 Feb 2023 11:03:40 -0500 Subject: [PATCH 1/4] update duplicated response options --- R/assemble.R | 7 +++++-- tests/testthat/test_strip_html.r | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/R/assemble.R b/R/assemble.R index 7758ad1..4215d89 100644 --- a/R/assemble.R +++ b/R/assemble.R @@ -14,7 +14,7 @@ #' @export parse_survey <- function( surv_obj, oauth_token = get_token(), ..., - fix_duplicates = c("error", "drop", "keep") + fix_duplicates = c("error", "drop", "keep", "none") ) { . <- NULL if (surv_obj$response_count == 0) { @@ -45,12 +45,15 @@ parse_survey <- function( # to deal with this add parameter fix_duplicate where default behaviour is to error, but # can be set to allow the function to continue and return. fix_duplicates <- match.arg(fix_duplicates) +browser() if (fix_duplicates == "error") { x <- duplicate_error(x) } else if (fix_duplicates == "keep") { x <- duplicate_keep(x) - } else { + } else if (fix_duplicates == "drop") { x <- duplicate_drop(x) + } else { + x } diff --git a/tests/testthat/test_strip_html.r b/tests/testthat/test_strip_html.r index 6642a68..b2952ad 100644 --- a/tests/testthat/test_strip_html.r +++ b/tests/testthat/test_strip_html.r @@ -6,8 +6,8 @@ test_that("all <> and values between are removed", { expect_equal( mtcars %>% dplyr::select( - "What is your favorite color?" = .data$mpg, - "Keep value" = .data$cyl + "What is your favorite color?" = "mpg", + "Keep value" = "cyl" ) %>% strip_html() %>% colnames(.), @@ -22,8 +22,8 @@ test_that("ignore values are kept", { expect_equal( mtcars %>% dplyr::select( - "What is your favorite color?" = .data$mpg, - "Keep value" = .data$cyl + "What is your favorite color?" = "mpg", + "Keep value" = "cyl" ) %>% strip_html(ignore = "this") %>% colnames(.), @@ -34,8 +34,8 @@ test_that("ignore values are kept", { test_that("warning when values are not found", { expect_warning(mtcars %>% dplyr::select( - "What is your favorite color?" = .data$mpg, - "Keep value" = .data$cyl + "What is your favorite color?" = "mpg", + "Keep value" = "cyl" ) %>% strip_html(ignore = "not_in_these_columns_satan!") %>% colnames(.), @@ -51,8 +51,8 @@ test_that("trim_space == TRUE is working correctly", { expect_equal( mtcars %>% dplyr::select( - "What is your favorite color?" = .data$mpg, - "Keep value" = .data$cyl + "What is your favorite color?" = "mpg", + "Keep value" = "cyl" ) %>% strip_html(trim_space = TRUE) %>% colnames(.), @@ -66,8 +66,8 @@ test_that("trim_space == FALSE is working correctly", { expect_equal( mtcars %>% dplyr::select( - "What is your favorite color?" = .data$mpg, - "Keep value" = .data$cyl + "What is your favorite color?" = "mpg", + "Keep value" = "cyl" ) %>% strip_html(trim_space = FALSE) %>% colnames(.), From 9d400168ec69403eaea6c9c05c3d4f03c8d08e00 Mon Sep 17 00:00:00 2001 From: Matt Roumaya Date: Sat, 4 Feb 2023 11:05:09 -0500 Subject: [PATCH 2/4] update --- DESCRIPTION | 2 +- R/assemble.R | 3 +++ man/parse_survey.Rd | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 005df35..b5db606 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,6 @@ Suggests: License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.1 URL: https://github.com/mattroumaya/surveymonkey BugReports: https://github.com/mattroumaya/surveymonkey/issues diff --git a/R/assemble.R b/R/assemble.R index 4215d89..7b307df 100644 --- a/R/assemble.R +++ b/R/assemble.R @@ -9,6 +9,9 @@ #' @param fix_duplicates character if 'error', the default detection of duplicate data will result #' in an error being raised, otherwise allow the function to return. If 'keep' duplicate results #' will be retained, if 'drop' duplicates will be removed from the results. +#' +#' If encountering issues with duplicates, use `fix_duplicates = 'none'` to deal with duplicate responses after +#' the survey is parsed. #' @return a data.frame (technically a \code{tibble}) with clean responses, one line per respondent. #' @importFrom rlang .data #' @export diff --git a/man/parse_survey.Rd b/man/parse_survey.Rd index a02ce0b..64651f6 100644 --- a/man/parse_survey.Rd +++ b/man/parse_survey.Rd @@ -8,7 +8,7 @@ parse_survey( surv_obj, oauth_token = get_token(), ..., - fix_duplicates = c("error", "drop", "keep") + fix_duplicates = c("error", "drop", "keep", "none") ) } \arguments{ @@ -22,7 +22,10 @@ parse_survey( \item{fix_duplicates}{character if 'error', the default detection of duplicate data will result in an error being raised, otherwise allow the function to return. If 'keep' duplicate results -will be retained, if 'drop' duplicates will be removed from the results.} +will be retained, if 'drop' duplicates will be removed from the results. + +If encountering issues with duplicates, use `fix_duplicates = 'none'` to deal with duplicate responses after +the survey is parsed.} } \value{ a data.frame (technically a \code{tibble}) with clean responses, one line per respondent. From fa6473e928ff51f77e52c9189fed684de44f4bd0 Mon Sep 17 00:00:00 2001 From: Matt Roumaya Date: Sat, 4 Feb 2023 11:09:45 -0500 Subject: [PATCH 3/4] fix ci --- .github/workflows/check-standard.yaml | 10 +++++----- .github/workflows/devtools-test.yaml | 4 ++-- .github/workflows/lint-project.yaml | 4 ++-- .github/workflows/pkgdown.yaml | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml index 91cddff..4a51020 100644 --- a/.github/workflows/check-standard.yaml +++ b/.github/workflows/check-standard.yaml @@ -29,21 +29,21 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: | testthat, httptest, rcmdcheck - - uses: r-lib/actions/check-r-package@v1 + - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/devtools-test.yaml b/.github/workflows/devtools-test.yaml index cb3567b..bd2e8ea 100644 --- a/.github/workflows/devtools-test.yaml +++ b/.github/workflows/devtools-test.yaml @@ -9,9 +9,9 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true diff --git a/.github/workflows/lint-project.yaml b/.github/workflows/lint-project.yaml index 730f4c3..471084b 100644 --- a/.github/workflows/lint-project.yaml +++ b/.github/workflows/lint-project.yaml @@ -11,9 +11,9 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5baaa4e..eb0d1f6 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -13,15 +13,15 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: pkgdown needs: website From 47c1505773521d941a414ded769ef141037ac94c Mon Sep 17 00:00:00 2001 From: Matt Roumaya Date: Sat, 4 Feb 2023 11:12:49 -0500 Subject: [PATCH 4/4] rm browser --- R/assemble.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/assemble.R b/R/assemble.R index 7b307df..62b4c5e 100644 --- a/R/assemble.R +++ b/R/assemble.R @@ -48,7 +48,7 @@ parse_survey <- function( # to deal with this add parameter fix_duplicate where default behaviour is to error, but # can be set to allow the function to continue and return. fix_duplicates <- match.arg(fix_duplicates) -browser() + if (fix_duplicates == "error") { x <- duplicate_error(x) } else if (fix_duplicates == "keep") {