You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/cancensus.R
+52-10Lines changed: 52 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@
24
24
#' for each census vector variable, containing the original suppression codes (e.g., 'x', 'F', '...')
25
25
#' before they are converted to NA. Useful for understanding data quality and suppression patterns.
26
26
#' Default is FALSE. Use \code{\link{census_data_quality}} to analyze suppression patterns.
27
+
#' @param retry Integer If greater than zero, automatically retry failed API requests with exponential backoff for specified maximum number of times. Defaults to 0.
27
28
#'
28
29
#' @source Census data and boundary geographies are reproduced and distributed on
29
30
#' an "as is" basis with the permission of Statistics Canada (Statistics Canada 1996; 2001; 2006; 2011; 2016).
@@ -56,8 +57,8 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
@@ -149,13 +150,32 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
149
150
stop(paste("No API key set. Use set_cancensus_api_key('<your API key>') to set one, or set_cancensus_api_key('<your API key>', install = TRUE) to save it permanently in your .Renviron."))
150
151
}
151
152
url<- paste0(base_url, "data.csv")
152
-
response<-if (!quiet) {
153
-
message("Querying CensusMapper API...")
154
-
httr::POST(url, httr::progress(), body=params)
153
+
if (!quiet) message("Querying CensusMapper API for data...")
if (!quiet&&!is.na(content_length) &&content_length>0) {
176
+
message(sprintf("Downloaded %s of data.", format_bytes(content_length)))
177
+
}
178
+
159
179
data_version<-response$headers$`data-version`
160
180
161
181
@@ -221,13 +241,32 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
221
241
stop(paste("No API key set. Use set_cancensus_api_key('<your API key>') to set one, or set_cancensus_api_key('<your API key>', install = TRUE) to save it permanently in your .Renviron."))
222
242
}
223
243
url<- paste0(base_url, "geo.geojson")
224
-
response<-if (!quiet) {
225
-
message("Querying CensusMapper API...")
226
-
httr::POST(url, httr::progress(),body=params)
244
+
if (!quiet) message("Querying CensusMapper API for geometry...")
0 commit comments