diff --git a/.github/workflows/R-CMD-check-all.yaml b/.github/workflows/R-CMD-check-all.yaml new file mode 100644 index 0000000..c06f2fd --- /dev/null +++ b/.github/workflows/R-CMD-check-all.yaml @@ -0,0 +1,53 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check-all.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + COMPILE_VIG: ${{ secrets.COMPILE_VIG }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - 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@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5762b51..55858f7 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,10 +1,6 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: - push: - branches: [main, master] - pull_request: - branches: [main, master] schedule: - cron: "15 15 * * *" @@ -23,10 +19,6 @@ jobs: matrix: config: - {os: macos-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-latest, r: 'release'} - - {os: ubuntu-latest, r: 'oldrel-1'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/R/cansim.R b/R/cansim.R index fbef320..cb2d7a9 100644 --- a/R/cansim.R +++ b/R/cansim.R @@ -2,13 +2,13 @@ #' #' Facilitates working with Statistics Canada data table values retrieved using the package by setting all units to counts/dollars instead of millions, etc. If "replacement_value" is not set, it will replace the \code{VALUE} field with normalized values and drop the \code{scale} column. Otherwise it will keep the scale columns and create a new column named replacement_value with the normalized value. It will attempt to parse the \code{REF_DATE} field and create an R date variable. This is currently experimental. #' -#' @param data A retrieved data table as returned from \code{get_cansim()} pr \code{get_cansim_ndm()} +#' @param data A retrieved data table as returned from \code{get_cansim()} or \code{get_cansim_ndm()} #' @param replacement_value (Optional) the name of the column the manipulated value should be returned in. Defaults to "val_norm" #' @param normalize_percent (Optional) When \code{TRUE} (the default) normalizes percentages by changing them to rates #' @param default_month The default month that should be used when creating Date objects for annual data (default set to "01") #' @param default_day The default day of the month that should be used when creating Date objects for monthly data (default set to "01") #' @param factors (Optional) Logical value indicating if dimensions should be converted to factors. (Default set to \code{TRUE}). -#' @param strip_classification_code (strip_classification_code) Logical value indicating if classification code should be stripped +#' @param strip_classification_code Logical value indicating if classification code should be stripped #' from names. (Default set to \code{FALSE}, if \code{factors=TRUE} this is overridden and set to \code{TRUE}). #' @param cansimTableNumber (Optional) Only needed when operating on results of SQLite connections. #' @param internal (Optional) Flag to indicate that this function is called internally. @@ -746,7 +746,7 @@ get_cansim_column_categories <- function(cansimTableNumber, column, language="en dplyr::pull(!!as.name(dimension_id_column)) data_path <- paste0(base_path_for_table_language(cleaned_number,language),".Rda_column_",column_index) if (!file.exists(data_path)){ - stop(paste0("Unkown column ",column),call.=FALSE) + stop(paste0("Unknown column ",column),call.=FALSE) } result <- readRDS(file=data_path) } else { @@ -781,7 +781,7 @@ get_cansim_column_categories <- function(cansimTableNumber, column, language="en exceeded_hierarchy_warning_message=exceeded_hierarchy_warning_message) if (nrow(result)==0){ - stop(paste0("Unkown column ",column),call.=FALSE) + stop(paste0("Unknown column ",column),call.=FALSE) } } diff --git a/R/cansim_helpers.R b/R/cansim_helpers.R index 2a433aa..0ac609f 100644 --- a/R/cansim_helpers.R +++ b/R/cansim_helpers.R @@ -41,7 +41,7 @@ table_base_path <- function(cansimTableNumber) { file_path_for_table_language <- function(cansimTableNumber, language){ language <- cleaned_ndm_language(language) - if (is.na(language)) stop(paste0("Unkown Lanaguage ",language),call.=FALSE) + if (is.na(language)) stop(paste0("Unknown Lanaguage ",language),call.=FALSE) base_table <- naked_ndm_table_number(cansimTableNumber) file.path(paste0(base_table,"-",language)) } @@ -88,7 +88,7 @@ get_with_timeout_retry <- function(url,timeout=200,retry=3,path=NA,warn_only=FAL if ("curl_error_peer_failed_verification" %in% class(response$error)) { stop(stringr::str_wrap(gsub(".+\\): ","",as.character(response$error),80)),"\n", "This means that the authenticity of the StatCan API server can't be verified.\n", - "Statistics Canada has a history of failty SSL certificats on their API,\n", + "Statistics Canada has a history of faulty SSL certificats on their API,\n", "if you are reasonably sure that your connection is not getting hijacked you\n", "can disable peer checking for the duration of the R session by typing\n\n", "httr::set_config(httr::config(ssl_verifypeer=0,ssl_verifystatus=0))","\n\n","into the console.",call.=FALSE) @@ -138,7 +138,7 @@ post_with_timeout_retry <- function(url,body,timeout=200,retry=3,warn_only=FALSE if ("curl_error_peer_failed_verification" %in% class(response$error)) { stop(stringr::str_wrap(gsub(".+\\): ","",as.character(response$error),80)),"\n", "This means that the authenticity of the StatCan API server can't be verified.\n", - "Statistics Canada has a history of failty SSL certificats on their API,\n", + "Statistics Canada has a history of faulty SSL certificats on their API,\n", "if you are reasonably sure that your connection is not getting hijacked you\n", "can disable peer checking for the duration of the R session by typing\n\n", "httr::set_config(httr::config(ssl_verifypeer=0,ssl_verifystatus=0))","\n\n","into the console.",call.=FALSE) @@ -359,7 +359,7 @@ transform_value_column <- function(data,value_column){ dplyr::mutate(!!value_column:=as.numeric(!!as.name(value_column))) } } else { - warning("Unkown table type") + warning("Unknown table type") } data } diff --git a/R/cansim_metadata.R b/R/cansim_metadata.R index 2745e9b..6a408c1 100644 --- a/R/cansim_metadata.R +++ b/R/cansim_metadata.R @@ -390,7 +390,7 @@ get_cansim_table_template <- function(cansimTableNumber, language="english",refr mutate(cansimTableNumber=!!cansimTableNumber,.before="COORDINATE") attr(result, "cansimTableNumber") <- cansimTableNumber - attr(result, "langauge") <- language + attr(result, "language") <- language result } diff --git a/R/cansim_parquet.R b/R/cansim_parquet.R index fa70ce0..12cb2bf 100644 --- a/R/cansim_parquet.R +++ b/R/cansim_parquet.R @@ -179,7 +179,7 @@ get_cansim_connection <- function(cansimTableNumber, } - hd <- header[duplicated(toupper(header))] + hd <- header[duplicated(toupper(header)) | duplicated(toupper(header), fromLast = TRUE)] if (length(hd)>0) { dupes <- header[toupper(header) %in% hd] @@ -616,7 +616,7 @@ list_cansim_cached_tables <- function(cache_path=Sys.getenv('CANSIM_CACHE_PATH') } result <- dplyr::tibble(path=dir(cache_path,"cansim_\\d+_parquet_eng|cansim_\\d+_parquet_fra|cansim_\\d+_feather_eng|cansim_\\d+_feather_fra|cansim_\\d+_sqlite_eng|cansim_\\d+_sqlite_fra")) %>% - dplyr::mutate(cansimTableNumber=gsub("^cansim_|_eng$|_fra$|_parquet_eng$|_parquet_fra|_feather_eng$|_feather_fra|_sqlite_eng$|_sqlte_fra$","",.data$path) %>% cleaned_ndm_table_number()) %>% + dplyr::mutate(cansimTableNumber=gsub("^cansim_|_eng$|_fra$|_parquet_eng$|_parquet_fra|_feather_eng$|_feather_fra|_sqlite_eng$|_sqlite_fra$","",.data$path) %>% cleaned_ndm_table_number()) %>% dplyr::mutate(dataFormat=case_when(grepl("_parquet",.data$path)~"parquet", grepl("_feather",.data$path)~"feather", grepl("_sqlite",.data$path)~"sqlite", diff --git a/R/cansim_sql.R b/R/cansim_sql.R index 5871df8..a34d5ed 100644 --- a/R/cansim_sql.R +++ b/R/cansim_sql.R @@ -25,7 +25,7 @@ TIME_FORMAT <- "%Y-%m-%d %H:%M:%S" #' con <- get_cansim_connection("34-10-0013", format="sqlite") #' #' # Work with the data connection -#' gplimpse(con) +#' glimpse(con) #' #' disconnect_cansim_sqlite(con) #' } diff --git a/R/cansim_tables_list.R b/R/cansim_tables_list.R index 9c184a8..8a01bdc 100644 --- a/R/cansim_tables_list.R +++ b/R/cansim_tables_list.R @@ -110,7 +110,7 @@ list_cansim_cubes <- function(lite=FALSE,refresh=FALSE,quiet=FALSE){ surveys_fr <- setNames(surveys$surveyFr,surveys$surveyCode) subjects <- get_cansim_code_set("subject") subjects_en <- setNames(subjects$subjectEn,subjects$subjectCode) - subjects_fr <- setNames(subjects$subjectEn,subjects$subjectCode) + subjects_fr <- setNames(subjects$subjectFr,subjects$subjectCode) if (lite) { r<-content %>% diff --git a/R/cansim_vectors.R b/R/cansim_vectors.R index 4945d21..35be22b 100644 --- a/R/cansim_vectors.R +++ b/R/cansim_vectors.R @@ -519,7 +519,7 @@ get_cansim_data_for_table_coord_periods<-function(tableCoordinates, periods=NULL } attr(result,"language") <- cleaned_language - if (!is.null(failed_coordinates) && nrow(failed_coordinates > 0)) { + if (!is.null(failed_coordinates) && nrow(failed_coordinates) > 0) { regular_fails <- failed_coordinates %>% filter(substr(.data$cansimTableNumber,1,4) != CENSUS_TABLE_STARTING_STRING) census_fails <- failed_coordinates %>%