diff --git a/.Rbuildignore b/.Rbuildignore index 6725110..6f14974 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,4 +12,4 @@ .RData ^_pkgdown\.yml$ ^pkgdown$ -^data_prep +^data_prep/ diff --git a/NEWS.md b/NEWS.md index 34d0895..b166d74 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,10 +7,13 @@ * Minor changes * Replaced `.onAttach` by `.onLoad` so that the package works with `censobr::function()` * Fixed documentation of various functions. + * Fixed issue to make sure censobr uses suggested packages conditionally on CRAN -* Data included in this version: +* New data set and files included in this version: * 2022 census [*New*] * Questionnaires and interview manuals + * Short questionnaires for every census between 1960 and 2022. + * Long questionnaire for the 1960 and 2022 censuses. # censobr v0.2.0 diff --git a/R/docs_questionnaire.R b/R/docs_questionnaire.R index 2c0debc..cc317a3 100644 --- a/R/docs_questionnaire.R +++ b/R/docs_questionnaire.R @@ -7,8 +7,8 @@ #' @template year #' @param type Character. The type of questionnaire used in the survey, whether #' the `"long"` one used in the sample component of the census, or the -#' `"short"` one, which is answered by more households. Options currently -#' include `c("long")`. +#' `"short"` one, which is answered by more households. Options include +#' `c("long", "short")`. #' @template showProgress #' @template cache #' @@ -25,7 +25,8 @@ questionnaire <- function(year = 2010, type = NULL, showProgress = TRUE, cache = TRUE){ - # year = 2010 + # year = 2000 + # type = 'short' # type = 'long' ### check inputs @@ -33,13 +34,13 @@ questionnaire <- function(year = 2010, checkmate::assert_string(type) # data available for the years: - years <- c(1970, 1980, 1991, 2000, 2010, 2022) + years <- c(1960, 1970, 1980, 1991, 2000, 2010, 2022) if (isFALSE(year %in% years)) { stop( paste0("Error: Questionnaire currently only available for the years: ", paste(years), collapse = " ") )} # data available for data sets: - data_sets <- c('long') + data_sets <- c('long', 'short') if (isFALSE(type %in% data_sets)) { stop( paste0("Error: Questionnaire currently only available for the types: ", paste(data_sets, collapse = ", ")) )} diff --git a/tests/testthat/test_docs_questionnaire.R b/tests/testthat/test_docs_questionnaire.R index 8078edd..a24c0f9 100644 --- a/tests/testthat/test_docs_questionnaire.R +++ b/tests/testthat/test_docs_questionnaire.R @@ -10,19 +10,21 @@ testthat::skip_on_cran() test_that("questionnaire", { # download files - testthat::expect_message( questionnaire(year = 2022, type = 'long') ) - testthat::expect_message( questionnaire(year = 2010, type = 'long') ) - testthat::expect_message( questionnaire(year = 2000, type = 'long') ) - testthat::expect_message( questionnaire(year = 1991, type = 'long') ) - testthat::expect_message( questionnaire(year = 1980, type = 'long') ) - testthat::expect_message( questionnaire(year = 1970, type = 'long') ) + for (y in c(1960, 1970, 1980, 1991, 2000, 2010, 2022)) { + + for (t in c('long', 'short')) { + testthat::expect_message(questionnaire(year = y, type = t)) + } + + } + # cache dir pkgv <- paste0('censobr/data_release_', data_release) cache_dir <- tools::R_user_dir(pkgv, which = 'cache') ## check if file have been downloaded - years <- c(1970, 1980, 1991, 2000, 2010, 2022) + years <- c(1960, 1970, 1980, 1991, 2000, 2010, 2022) lapply(X=years, FUN = function(y){ f_address <- paste0(cache_dir,'/',y, '_questionnaire_long.pdf')