Skip to content
Open
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
53 changes: 53 additions & 0 deletions .github/workflows/R-CMD-check-all.yaml
Original file line number Diff line number Diff line change
@@ -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")'
8 changes: 0 additions & 8 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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 * * *"

Expand All @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions R/cansim.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand Down
8 changes: 4 additions & 4 deletions R/cansim_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion R/cansim_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions R/cansim_parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion R/cansim_sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#' }
Expand Down
2 changes: 1 addition & 1 deletion R/cansim_tables_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>%
Expand Down
2 changes: 1 addition & 1 deletion R/cansim_vectors.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>%
Expand Down
Loading