Skip to content

Commit

Permalink
Census API Update
Browse files Browse the repository at this point in the history
  • Loading branch information
kkprinceton committed Feb 11, 2019
1 parent 73787e5 commit 963af0d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions R/census_geo_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ census_geo_api <- function(key, state, geo = "tract", age = FALSE, sex = FALSE,

fips.codes <- get("State.FIPS")
state.fips <- fips.codes[fips.codes$State == state, "FIPS"]
state.fips <- ifelse(nchar(state.fips) == 1, paste0("0", state.fips), state.fips)

if (age == F & sex == F) {
num <- ifelse(3:10 != 10, paste("0", 3:10, sep = ""), "10")
Expand Down
2 changes: 1 addition & 1 deletion R/get_census_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ get_census_api <- function(data_url, key, vars, region, retry = 0) {
if(length(vars) > 50){
vars <- vec_to_chunk(vars) # Split variables into a list
get <- lapply(vars, function(x) paste(x, sep='', collapse=","))
data <- lapply(vars, function(x) get_census_api_2(data_url,key, x, region, retry))
data <- lapply(vars, function(x) get_census_api_2(data_url, key, x, region, retry))
} else {
get <- paste(vars, sep='', collapse=',')
data <- list(get_census_api_2(data_url, key, get, region, retry))
Expand Down
2 changes: 1 addition & 1 deletion R/get_census_api_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' @export
get_census_api_2 <- function(data_url, key, get, region, retry = 0){
if(length(get)>1) {
if(length(get) > 1) {
get <- paste(get, collapse=',', sep='')
}
api_call <- paste(data_url, 'key=', key, '&get=', get, '&', region, sep='')
Expand Down

0 comments on commit 963af0d

Please sign in to comment.