Skip to content

Commit 13d4e07

Browse files
committed
update documentation, enable scheduled daily GitHub checks, remove deprecated adjust_cansim_values_by_variable function.
1 parent 3467275 commit 13d4e07

57 files changed

Lines changed: 155 additions & 121 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R-CMD-check.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ on:
1313
branches:
1414
- main
1515
- master
16+
schedule:
17+
- cron: "15 15 * * *"
1618

1719
name: R-CMD-check
1820

CRAN-RELEASE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
This package was submitted to CRAN on 2021-05-08.
2-
Once it is accepted, delete this file and tag the release (commit 7ff77e4).
1+
This package was submitted to CRAN on 2021-05-24.
2+
Once it is accepted, delete this file and tag the release (commit 3467275).

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(add_provincial_abbreviations)
4-
export(adjust_cansim_values_by_variable)
54
export(cansim_old_to_new)
65
export(categories_for_level)
76
export(collect_and_normalize)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# cansim 0.3.8
22
## Minor changes
3-
* Exclude vignette from CRAN checks
3+
* Exclude vignette from automatic CRAN checks to fix problem of CRAN checks failing when StatCan servers are down and lead to the package being removed from CRAN (checks are still active in local environment and when using GitHub action checks)
44
* add release date info to cube metadata and cube list calls
55
* add auto-refresh option for sqlite tables
6+
* remove deprecated `adjust_cansim_values_by_variable` function
67

78
# cansim 0.3.7
89
## Minor changes

R/cansim.R

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
1212
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
1313
#'
14-
#' @return tibble format data table output
14+
#' @return A tibble with the StatCan table data
1515
#'
1616
#' @examples
1717
#' \donttest{
@@ -27,17 +27,6 @@ get_cansim_ndm <- function(cansimTableNumber, language="english", refresh=FALSE,
2727
}
2828

2929

30-
#' (Deprecated) Adjust values in a retrieved Statistics Canada data table using a scaling variable
31-
#'
32-
#' (Deprecated) Adjust retrieved data table values by a scaled amount; however French does not work, probably due to encoding issues. This function is now deprecated and should not be used.
33-
#'
34-
#' @param data A downloaded CANSIM data table
35-
#' @param var A now deprecated input
36-
#'
37-
#' @export
38-
adjust_cansim_values_by_variable <-function(data, var){
39-
normalize_cansim_values(data)
40-
}
4130

4231
#' Normalize retrieved data table values to appropriate scales
4332
#'
@@ -206,7 +195,7 @@ normalize_cansim_values <- function(data, replacement_value=NA, normalize_percen
206195
#'
207196
#' @param oldCansimTableNumber deprecated style CANSIM table number (e.g. "427-0001")
208197
#'
209-
#' @return new-format NDM table number
198+
#' @return A character string with the new-format NDM table number
210199
#'
211200
#' @examples
212201
#' \donttest{
@@ -240,6 +229,7 @@ cansim_old_to_new <- function(oldCansimTableNumber){
240229
#' Parse metadata
241230
#' @param meta the raw metadata table
242231
#' @param data_path base path to save parsed metadata
232+
#'
243233
#' @return NULL
244234
#' @keywords internal
245235
parse_metadata <- function(meta,data_path){
@@ -333,10 +323,11 @@ parse_metadata <- function(meta,data_path){
333323
}
334324

335325
#' Fold in metadata and for selected columns
336-
#' @param data the data table
326+
#' @param data A tibble with StatCan table data as e.g. returned by \code{get_cansim}.
337327
#' @param data_path base path to save parsed metadata
338328
#' @param column_names the names of the columns
339-
#' @return data table including the metadata information
329+
#'
330+
#' @return A tibble including the metadata information
340331
#' @keywords internal
341332
fold_in_metadata_for_columns <- function(data,data_path,column_names){
342333
cleaned_language <- basename(data_path) %>% gsub("^.+-|\\..+$","",.)
@@ -415,11 +406,12 @@ fold_in_metadata_for_columns <- function(data,data_path,column_names){
415406
#' @keywords data
416407
NULL
417408

418-
#' Parse metadata and fold into data table (deprecated)
409+
#' Parse metadata and fold into tibble (deprecated)
419410
#' @param data the data table
420411
#' @param meta the raw metadata table
421412
#' @param data_path base path to save parsed metadata
422-
#' @return data table including the metadata information
413+
#'
414+
#' @return A tibble including the metadata information
423415
#' @keywords internal
424416
parse_and_fold_in_metadata <- function(data,meta,data_path){
425417
cleaned_language <- ifelse("VALEUR" %in% names(data),"fra","eng")
@@ -555,8 +547,8 @@ parse_and_fold_in_metadata <- function(data,meta,data_path){
555547
#' @param default_day The default day of the month that should be used when creating Date objects for monthly data (default set to "01")
556548
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
557549
#'
558-
#' @return tibble format data table output with added Date column with inferred date objects and
559-
#' a "val_norm" column with normalized VALUE using the supplied scale factor
550+
#' @return A tibble with StatCan Table data and added \code{Date} column with inferred date objects and
551+
#' added \code{val_norm} column with normalized value from the \code{VALUE} column.
560552
#'
561553
#' @examples
562554
#' \donttest{
@@ -639,6 +631,8 @@ get_cansim <- function(cansimTableNumber, language="english", refresh=FALSE, tim
639631
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
640632
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
641633
#'
634+
#' @return A tibble with the table overview information
635+
#'
642636
#' @examples
643637
#' \donttest{
644638
#' get_cansim_table_info("34-10-0013")
@@ -663,6 +657,8 @@ get_cansim_table_info <- function(cansimTableNumber, language="english", refresh
663657
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
664658
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
665659
#'
660+
#' @return A tibble with the table survey code and name
661+
#'
666662
#' @examples
667663
#' \donttest{
668664
#' get_cansim_table_survey("34-10-0013")
@@ -686,6 +682,8 @@ get_cansim_table_survey <- function(cansimTableNumber, language="english", refre
686682
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
687683
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
688684
#'
685+
#' @return A tibble with the table subject code and name.
686+
#'
689687
#' @examples
690688
#' \donttest{
691689
#' get_cansim_table_subject("34-10-0013")
@@ -709,6 +707,8 @@ get_cansim_table_subject <- function(cansimTableNumber, language="english", refr
709707
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
710708
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
711709
#'
710+
#' @return A tibble with the StatCan Notes for the table
711+
#'
712712
#' @examples
713713
#' \donttest{
714714
#' get_cansim_table_short_notes("34-10-0013")
@@ -732,6 +732,8 @@ get_cansim_table_short_notes <- function(cansimTableNumber, language="english",
732732
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
733733
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
734734
#'
735+
#' @return A tibble listing the column names of the StatCan table.
736+
#'
735737
#' @examples
736738
#' \donttest{
737739
#' get_cansim_column_list("34-10-0013")
@@ -756,6 +758,8 @@ get_cansim_column_list <- function(cansimTableNumber, language="english", refres
756758
#' @param timeout (Optional) Timeout in seconds for downloading cansim table to work around scenarios where StatCan servers drop the network connection.
757759
# Set to higher values for large tables and slow network connection. (Default is \code{200}).
758760
#'
761+
#' @return A tibble with detailed information on StatCan table categories for the specified field
762+
#'
759763
#' @examples
760764
#' \donttest{
761765
#' get_cansim_column_categories("34-10-0013", "Geography")

R/cansim_helpers.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ short_prov.fr <- purrr::set_names(c(
180180

181181
#' Add provincial abbreviations as factor
182182
#' @export
183-
#' @param data code{cansim} package data frame with provincial level data
184-
#' @return a code{cansim} package data frame with additional factor GEO.abb that contains language-specific provincial abbreviations
183+
#' @param data A tibble as returned by \code{get_cansim} with provincial level data
184+
#' @return The input tibble with additional factor GEO.abb that contains language-specific provincial abbreviations
185185
#'
186186
#' @examples
187187
#' \donttest{
@@ -210,7 +210,8 @@ add_provincial_abbreviations <- function(data){
210210
#' @param code_set the code set to retrieve.
211211
#' @param refresh Default is \code{FALSE}, repeated calls during the same session will hit the cached data.
212212
#' To refresh the code list during a running R session set to \code{TRUE}
213-
#' @return a tibble with english and french labels for the given code set
213+
#'
214+
#' @return A tibble with english and french labels for the given code set
214215
#'
215216
#' @examples
216217
#' \donttest{

R/cansim_sql.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ TIME_FORMAT <- "%Y-%m-%d %H:%M:%S"
1818
#' in the path specified by `getOption("cansim.cache_path")`, if this is set. Otherwise it will use `tempdir()`.
1919
# Set to higher values for large tables and slow network connection. (Default is \code{1000}).
2020
#'
21-
#' @return tibble format data table output with added Date column with inferred date objects and
22-
#' a "val_norm" column with normalized VALUE using the supplied scale factor
21+
#' @return A database connection to a local SQLite database with the StatCan Table data.
2322
#'
2423
#' @examples
2524
#' \donttest{
@@ -201,7 +200,7 @@ get_cansim_sqlite <- function(cansimTableNumber, language="english", refresh=FAL
201200
con
202201
}
203202

204-
#' disconnect from a cansim database connection
203+
#' Disconnect from a cansim database connection
205204
#'
206205
#' @param connection connection to database
207206
#' @return `NULL``
@@ -216,16 +215,17 @@ disconnect_cansim_sqlite <- function(connection){
216215
DBI::dbDisconnect(connection$src$con)
217216
}
218217

219-
#' collect data from connection and normalize cansim table output
218+
#' Collect data from connection and normalize cansim table output
220219
#'
221-
#' @param connection connection to database
220+
#' @param connection A connection to a local StatCan table SQLite database as returned by \code{get_cansim_sqlite},
221+
#' possibly with filters or other \code{dbplyr} verbs applied
222222
#' @param replacement_value (Optional) the name of the column the manipulated value should be returned in. Defaults to adding the `val_norm` value field.
223223
#' @param normalize_percent (Optional) When \code{true} (the default) normalizes percentages by changing them to rates
224224
#' @param default_month The default month that should be used when creating Date objects for annual data (default set to "01")
225225
#' @param default_day The default day of the month that should be used when creating Date objects for monthly data (default set to "01")
226226
#' @param factors (Optional) Logical value indicating if dimensions should be converted to factors. (Default set to \code{false}).
227227
#' @param strip_classification_code (strip_classification_code) Logical value indicating if classification code should be stripped from names. (Default set to \code{false}).
228-
#' @return a tibble with the normalized data
228+
#' @return A tibble with the collected and normalized data
229229
#'
230230
#' @examples
231231
#' \donttest{
@@ -358,6 +358,7 @@ remove_cansim_sqlite_cached_table <- function(cansimTableNumber,language=NULL,ca
358358
#' @param connection connection to database
359359
#' @param table_name sql table name
360360
#' @param field name of field to index
361+
#' @return `NULL``
361362
#' @keywords internal
362363
create_index <- function(connection,table_name,field){
363364
field_index=paste0("index_",gsub("[^[:alnum:]]","_",field))
@@ -384,6 +385,8 @@ create_index <- function(connection,table_name,field){
384385
#' @param na na character strings
385386
#' @param text_encoding encoding of csv file (default UTF-8)
386387
#' @param delim (Optional) csv deliminator, default is ","
388+
#'
389+
#' @return A database connection
387390
#' @keywords internal
388391
csv2sqlite <- function(csv_file, sqlite_file, table_name, transform=NULL,chunk_size=5000000,
389392
append=FALSE,col_types=NULL,na=c(NA,"..","","...","F"),

cran-comments.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ There were no ERRORs or WARNINGs or NOTEs.
5555

5656
# Changes from version 0.3.7
5757
## Minor changes
58-
* Exclude vignette from CRAN checks
58+
* Exclude vignette from automatic CRAN checks to fix problem of CRAN checks failing when StatCan servers are down and lead to the package being removed from CRAN (checks are still active in local environment and when using GitHub action checks)
5959
* add release date info to cube metadata and cube list calls
6060
* add auto-refresh option for sqlite tables
61+
* remove deprecated `adjust_cansim_values_by_variable` function

docs/articles/cansim.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/listing_cansim_tables.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)