diff --git a/R/get_census_api_2.R b/R/get_census_api_2.R index 390bdde..1920658 100644 --- a/R/get_census_api_2.R +++ b/R/get_census_api_2.R @@ -22,8 +22,8 @@ #' If unsuccessful, function prints the URL query that was constructed. #' #' @examples -#' \dontrun{get_census_api_2(data_url = "https://api.census.gov/data/2010/dec/sf1?", key = "...", -#' get = c("P005003","P005004","P005005", "P005006"), region = "for=county:*&in=state:34")} +#' \dontrun{try(get_census_api_2(data_url = "https://api.census.gov/data/2010/dec/sf1?", key = "...", +#' get = c("P005003","P005004","P005005", "P005006"), region = "for=county:*&in=state:34"))} #' #' @references #' Based on code authored by Nicholas Nagle, which is available diff --git a/R/merge_names.R b/R/merge_names.R index c54d705..4fe4cbe 100644 --- a/R/merge_names.R +++ b/R/merge_names.R @@ -64,7 +64,7 @@ #' @importFrom dplyr coalesce #' @examples #' data(voters) -#' \dontrun{merge_names(voters, namesToUse = "surname", census.surname = TRUE)} +#' \dontrun{try(merge_names(voters, namesToUse = "surname", census.surname = TRUE))} #' @keywords internal merge_names <- function(voter.file, namesToUse, census.surname, table.surnames = NULL, table.first = NULL, table.middle = NULL, clean.names = TRUE, impute.missing = FALSE, model = "BISG") { diff --git a/R/merge_surnames.R b/R/merge_surnames.R index 45c85cb..f7c6cd4 100644 --- a/R/merge_surnames.R +++ b/R/merge_surnames.R @@ -50,7 +50,7 @@ #'#' #' @examples #' data(voters) -#' \dontrun{merge_surnames(voters)} +#' \dontrun{try(merge_surnames(voters))} #' #' @keywords internal diff --git a/R/predict_race.R b/R/predict_race.R index 85263e9..aea58f6 100644 --- a/R/predict_race.R +++ b/R/predict_race.R @@ -107,24 +107,28 @@ #' #' @examples #' data(voters) -#' predict_race(voter.file = voters, surname.only = TRUE) +#' try(predict_race(voter.file = voters, surname.only = TRUE)) #' \dontrun{ -#' predict_race(voter.file = voters, census.geo = "tract", census.key = "...") +#' try(predict_race(voter.file = voters, census.geo = "tract", census.key = "...")) #' } #' \dontrun{ -#' predict_race(voter.file = voters, census.geo = "place", census.key = "...", year = "2020") +#' try(predict_race( +#' voter.file = voters, census.geo = "place", census.key = "...", year = "2020")) #' } #' \dontrun{ -#' CensusObj <- get_census_data("...", state = c("NY", "DC", "NJ")) -#' predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj, party = "PID") +#' CensusObj <- try(get_census_data("...", state = c("NY", "DC", "NJ"))) +#' try(predict_race( +#' voter.file = voters, census.geo = "tract", census.data = CensusObj, party = "PID") +#' ) #' } #' \dontrun{ -#' CensusObj2 <- get_census_data(key = "...", state = c("NY", "DC", "NJ"), age = T, sex = T) -#' predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj2, age = T, sex = T) +#' CensusObj2 <- try(get_census_data(key = "...", state = c("NY", "DC", "NJ"), age = T, sex = T)) +#' try(predict_race( +#' voter.file = voters, census.geo = "tract", census.data = CensusObj2, age = T, sex = T)) #' } #' \dontrun{ -#' CensusObj3 <- get_census_data(key = "...", state = c("NY", "DC", "NJ"), census.geo = "place") -#' predict_race(voter.file = voters, census.geo = "place", census.data = CensusObj3) +#' CensusObj3 <- try(get_census_data(key = "...", state = c("NY", "DC", "NJ"), census.geo = "place")) +#' try(predict_race(voter.file = voters, census.geo = "place", census.data = CensusObj3)) #' } #' @export diff --git a/README.md b/README.md index 1fbabd1..f26ff01 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ predict_race(voter.file = voters.dc.nj, census.geo = "county", census.data = cen predict_race(voter.file = voters.dc.nj, census.geo = "tract", census.data = census.dc.nj2, party = "PID", age = TRUE, sex = FALSE) # Pr(Race | Surname, Tract, Party) ``` -Or you can also use the census_geo_api() to maually construct a census object. The example below creates a census object with county-level and tract-level data in DC and NJ, while avoiding downloading block-level data. Note that this function has the input parameter 'state' that requires a two-letter state abbreviation to proceed. +Or you can also use the census_geo_api() to manually construct a census object. The example below creates a census object with county-level and tract-level data in DC and NJ, while avoiding downloading block-level data. Note that this function has the input parameter 'state' that requires a two-letter state abbreviation to proceed. ``` r censusObj2 = list() diff --git a/man/format_legacy_data.Rd b/man/format_legacy_data.Rd index 5958c9f..eefc5f3 100644 --- a/man/format_legacy_data.Rd +++ b/man/format_legacy_data.Rd @@ -29,7 +29,7 @@ available for the 2020 Census as of September 2021. } \examples{ \dontrun{ -gaCensusData <- format_legacy_data('ga2020.pl') +gaCensusData <- format_legacy_data(PL94171::pl_url('GA', 2020)) predict_race_new(ga.voter.file, namesToUse = 'last, first, mid', census.geo = 'block', census.data = gaCensusData) } diff --git a/man/get_census_api_2.Rd b/man/get_census_api_2.Rd index ec604a5..4b43f27 100644 --- a/man/get_census_api_2.Rd +++ b/man/get_census_api_2.Rd @@ -37,8 +37,8 @@ It is used by the \code{get_census_api} function. The user should not need to ca function directly. } \examples{ -\dontrun{get_census_api_2(data_url = "https://api.census.gov/data/2010/dec/sf1?", key = "...", -get = c("P005003","P005004","P005005", "P005006"), region = "for=county:*&in=state:34")} +\dontrun{try(get_census_api_2(data_url = "https://api.census.gov/data/2010/dec/sf1?", key = "...", +get = c("P005003","P005004","P005005", "P005006"), region = "for=county:*&in=state:34"))} } \references{ diff --git a/man/merge_names.Rd b/man/merge_names.Rd index 4fcaa3b..114c6fe 100644 --- a/man/merge_names.Rd +++ b/man/merge_names.Rd @@ -93,6 +93,6 @@ This function allows users to match names in their dataset with database entries } \examples{ data(voters) -\dontrun{merge_names(voters, namesToUse = "surname", census.surname = TRUE)} +\dontrun{try(merge_names(voters, namesToUse = "surname", census.surname = TRUE))} } \keyword{internal} diff --git a/man/merge_surnames.Rd b/man/merge_surnames.Rd index e3490a5..ba4a071 100644 --- a/man/merge_surnames.Rd +++ b/man/merge_surnames.Rd @@ -72,7 +72,7 @@ This function allows users to match surnames in their dataset with the U.S. } \examples{ data(voters) -\dontrun{merge_surnames(voters)} +\dontrun{try(merge_surnames(voters))} } \keyword{internal} diff --git a/man/predict_race.Rd b/man/predict_race.Rd index 7649a7a..8900357 100644 --- a/man/predict_race.Rd +++ b/man/predict_race.Rd @@ -156,23 +156,23 @@ individual-level race/ethnicity, based on surname, geolocation, and party. } \examples{ data(voters) -predict_race(voter.file = voters, surname.only = TRUE) +try(predict_race(voter.file = voters, surname.only = TRUE)) \dontrun{ -predict_race(voter.file = voters, census.geo = "tract", census.key = "...") +try(predict_race(voter.file = voters, census.geo = "tract", census.key = "...")) } \dontrun{ -predict_race(voter.file = voters, census.geo = "place", census.key = "...", year = "2020") +try(predict_race(voter.file = voters, census.geo = "place", census.key = "...", year = "2020")) } \dontrun{ -CensusObj <- get_census_data("...", state = c("NY", "DC", "NJ")) -predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj, party = "PID") +CensusObj <- try(get_census_data("...", state = c("NY", "DC", "NJ"))) +try(predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj, party = "PID")) } \dontrun{ -CensusObj2 <- get_census_data(key = "...", state = c("NY", "DC", "NJ"), age = T, sex = T) -predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj2, age = T, sex = T) +CensusObj2 <- try(get_census_data(key = "...", state = c("NY", "DC", "NJ"), age = T, sex = T)) +try(predict_race(voter.file = voters, census.geo = "tract", census.data = CensusObj2, age = T, sex = T)) } \dontrun{ -CensusObj3 <- get_census_data(key = "...", state = c("NY", "DC", "NJ"), census.geo = "place") -predict_race(voter.file = voters, census.geo = "place", census.data = CensusObj3) +CensusObj3 <- try(get_census_data(key = "...", state = c("NY", "DC", "NJ"), census.geo = "place")) +try(predict_race(voter.file = voters, census.geo = "place", census.data = CensusObj3)) } }