|
|
@@ -25,7 +25,7 @@ |
|
|
#' U.S. Social Security Administration baby name data. (This method is based
|
|
|
#' on an implementation by Cameron Blevins.) The \code{"ipums"} method looks
|
|
|
#' up names from the U.S. Census data in the Integrated Public Use Microdata
|
|
|
-#' Series. (This method was contributed by Ben Schmidt.) The \code{"napp"}
|
|
|
+#' Series. (This method was contributed by Ben Schmidt.) The \code{"napp"}
|
|
|
#' method uses census microdata from Canada, Great Britain, Germany,
|
|
|
#' Iceland, Norway, and Sweden from 1801 to 1910 created by the
|
|
|
#' \href{https://www.nappdata.org/napp/}{North Atlantic Population Project}.
|
|
|
@@ -104,15 +104,19 @@ gender <- function(names, years = c(1932, 2012), |
|
|
# Hand off the arguments to functions based on method, and do error checking
|
|
|
if (method == "ssa") {
|
|
|
if (years[1] < 1880 || years[2] > 2012) {
|
|
|
- stop("Please provide a year range between 1880 and 2012.")
|
|
|
+ warning("The year range provided has been trimmed to fit within 1880 to 2012.")
|
|
|
+ if (years[1] < 1880) years[1] <- 1880
|
|
|
+ if (years[2] > 2012) years[2] <- 2012
|
|
|
}
|
|
|
if (!missing(countries) && countries != "United States") {
|
|
|
stop("SSA data is only available for the United States of America.")
|
|
|
}
|
|
|
gender_ssa(names = names, years = years)
|
|
|
} else if (method == "demo") {
|
|
|
if (years[1] < 1880 || years[2] > 2012) {
|
|
|
- stop("Please provide a year range between 1880 and 2012.")
|
|
|
+ warning("The year range provided has been trimmed to fit within 1880 to 2012.")
|
|
|
+ if (years[1] < 1880) years[1] <- 1880
|
|
|
+ if (years[2] > 2012) years[2] <- 2012
|
|
|
}
|
|
|
if (!missing(countries) && countries != "United States") {
|
|
|
stop("Demo data is only available for the United States of America.")
|
|
|
@@ -126,23 +130,28 @@ gender <- function(names, years = c(1932, 2012), |
|
|
gender_kantrowitz(names = names)
|
|
|
} else if (method == "ipums") {
|
|
|
if (years[1] < 1789 || years[2] > 1930) {
|
|
|
- stop("Please provide a year range between 1789 and 1930.")
|
|
|
+ warning("The year range provided has been trimmed to fit within 1789 to 1930.")
|
|
|
+ if (years[1] < 1789) years[1] <- 1789
|
|
|
+ if (years[2] > 1930) years[2] <- 1930
|
|
|
}
|
|
|
if (!missing(countries) && countries != "United States") {
|
|
|
stop("IPUMS data is only available for the United States of America.")
|
|
|
}
|
|
|
gender_ipums_usa(names = names, years = years)
|
|
|
} else if (method == "napp") {
|
|
|
- if (years[1] < 1758 || years[2] > 1910)
|
|
|
- stop("Please provide a year range between 1758 and 1910.")
|
|
|
+ if (years[1] < 1758 || years[2] > 1910) {
|
|
|
+ warning("The year range provided has been trimmed to fit within 1758 to 1910.")
|
|
|
+ if (years[1] < 1758) years[1] <- 1758
|
|
|
+ if (years[2] > 1910) years[2] <- 1910
|
|
|
+ }
|
|
|
if (missing(countries))
|
|
|
countries <- countries[countries != "United States"]
|
|
|
countries <- match.arg(countries, several.ok = TRUE)
|
|
|
if ("United States" %in% countries)
|
|
|
stop("NAPP data is only available for European countries. See ",
|
|
|
"the documentation.")
|
|
|
gender_napp(names = names, years = years, countries = countries)
|
|
|
- }else if (method == "genderize") {
|
|
|
+ } else if (method == "genderize") {
|
|
|
if (!missing(years))
|
|
|
stop("Genderize method does not account for year.")
|
|
|
if (!missing(countries))
|
|
|
|
0 comments on commit
ecd6bf7