From 51a0fd72c69ab01a89fb3b5242e45d879093a45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mine=20=C3=87etinkaya-Rundel?= Date: Sat, 1 Jun 2024 15:05:07 -0400 Subject: [PATCH] Fix URLs and styling --- R/data-gerrymander.R | 24 +++++++++---------- R/data-prez_pwr.R | 5 ++-- R/data-prrace08.R | 2 +- R/data-state_stats.R | 4 ++-- R/data-us_crime_rates.R | 2 +- R/data-us_time_survey.R | 22 ++++++++--------- R/data-vote_nsa.R | 2 +- R/data-voter_count.R | 2 +- data-raw/gerrymander/gerrymander-dataprep.R | 18 +++++++------- .../us_time_survey/us_time_survey-dataprep.R | 1 - man/gerrymander.Rd | 20 ++++++++-------- man/prez_pwr.Rd | 3 +-- man/state_stats.Rd | 2 +- man/us_crime_rates.Rd | 2 +- man/us_time_survey.Rd | 16 ++++++------- man/voter_count.Rd | 2 +- 16 files changed, 63 insertions(+), 64 deletions(-) diff --git a/R/data-gerrymander.R b/R/data-gerrymander.R index 49ef50e..861bc98 100644 --- a/R/data-gerrymander.R +++ b/R/data-gerrymander.R @@ -4,7 +4,7 @@ #' #' @name gerrymander #' @docType data -#' @format A data frame with 435 rows and 12 variables: +#' @format A data frame with 435 rows and 12 variables: #' \describe{ #' \item{district}{Congressional district.} #' \item{last_name}{Last name of 2016 election winner.} @@ -22,18 +22,18 @@ #' @source [Washington Post](https://www.washingtonpost.com/news/wonk/wp/2014/05/15/americas-most-gerrymandered-congressional-districts/) #' @keywords datasets #' -#' @examples +#' @examples #' library(ggplot2) #' library(dplyr) #' ggplot(gerrymander |> filter(gerry != "mid"), aes(clinton16, dem16, color = gerry)) + -#' geom_jitter(height = 0.05, size = 3, shape = 1) + -#' geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE) + -#' scale_color_manual(values = c("purple", "orange")) + -#' labs( -#' title = "Logistic Regression of 2016 House Elections", -#' subtitle = "by Congressional District", -#' x = "Percent of Presidential Vote Won by Clinton", -#' y = "Seat Won by Democrat Candidate", -#' color = "Gerrymandering" -#' ) +#' geom_jitter(height = 0.05, size = 3, shape = 1) + +#' geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE) + +#' scale_color_manual(values = c("purple", "orange")) + +#' labs( +#' title = "Logistic Regression of 2016 House Elections", +#' subtitle = "by Congressional District", +#' x = "Percent of Presidential Vote Won by Clinton", +#' y = "Seat Won by Democrat Candidate", +#' color = "Gerrymandering" +#' ) "gerrymander" diff --git a/R/data-prez_pwr.R b/R/data-prez_pwr.R index 43ec1e7..9f129df 100644 --- a/R/data-prez_pwr.R +++ b/R/data-prez_pwr.R @@ -25,8 +25,7 @@ #' fill = "Respondent Party" #' ) + #' facet_wrap(~president) -#' @source -#' [Pew Research Center, May 2006 & March 2012](https://www.pewresearch.org/fact-tank/2013/07/25/can-a-president-control-gas-prices-depends-on-when-you-ask/). -#' @keywords datasets +#' @source [Pew Research Center, May 2006 & March 2012](https://www.pewresearch.org/short-reads/2013/07/25/can-a-president-control-gas-prices-depends-on-when-you-ask/). +#' @keywords datasets #' "prez_pwr" diff --git a/R/data-prrace08.R b/R/data-prrace08.R index ad2d27f..6b610c0 100644 --- a/R/data-prrace08.R +++ b/R/data-prrace08.R @@ -17,7 +17,7 @@ #' \item{p_mc_cain}{Proportion of votes for John McCain} #' \item{el_votes}{Number of electoral votes for a state} #' } -#' @source \href{https://www.infoplease.com/us/government/elections/presidential-election-of-2008-electoral-and-popular-vote-summary}{Presidential Election of 2008, Electoral and Popular Vote Summary}, +#' @source [Presidential Election of 2008, Electoral and Popular Vote Summary](https://www.infoplease.com/us/government/elections/presidential-election-of-2008-electoral-and-popular-vote-summary), #' retrieved 2011-04-21. #' @keywords datasets election 2008 president United States #' @examples diff --git a/R/data-state_stats.R b/R/data-state_stats.R index 6284153..0a345c1 100644 --- a/R/data-state_stats.R +++ b/R/data-state_stats.R @@ -37,9 +37,9 @@ #' } #' @source Census Quick Facts (no longer available as of 2020), #' InfoChimps (also no longer available as of 2020), -#' \href{https://www-fars.nhtsa.dot.gov/Main/index.aspx}{National Highway Traffic Safety Administration}, +#' [National Highway Traffic Safety Administration](https://www-fars.nhtsa.dot.gov/Main/index.aspx) #' ({\code{tr_deaths}, \code{tr_deaths_no_alc}}), -#' \href{https://www.bls.gov/web/laus/laumstrk.htm}{Bureau of Labor Statistics} +#' [Bureau of Labor Statistics](https://www.bls.gov/web/laus/laumstrk.htm) #' (\code{unempl}). #' @keywords datasets state United States crime energy #' @examples diff --git a/R/data-us_crime_rates.R b/R/data-us_crime_rates.R index 014d3a6..a730c41 100644 --- a/R/data-us_crime_rates.R +++ b/R/data-us_crime_rates.R @@ -19,7 +19,7 @@ #' \item{vehicle_theft}{Number of vehicle thefts committed. Counted in property total.} #' } #' -#' @source \href{http://www.disastercenter.com/crime/uscrime.htm}{Disaster Center} +#' @source [Disaster Center](https://www.disastercenter.com/crime/uscrime.htm) #' #' @examples #' diff --git a/R/data-us_time_survey.R b/R/data-us_time_survey.R index 4e9906e..19e6d25 100644 --- a/R/data-us_time_survey.R +++ b/R/data-us_time_survey.R @@ -1,7 +1,7 @@ #' American Time Survey 2009 - 2019 #' #' Average Time Spent on Activities by Americans -#' +#' #' @name us_time_survey #' @docType data #' @format A data frame with 11 rows and 8 variables. @@ -14,20 +14,20 @@ #' \item{caring_children}{Average hours spent per day caring for and helping children under 18 years of age.} #' \item{working_employed}{Average hours spent working for those employed. (15 years and older)} #' \item{working_employed_days_worked}{Average hours per day spent working on days worked (15 years and older)} -#' +#' #' } #' #' @examples #' -#'library(ggplot2) -#'us_time_survey$year <-as.factor(us_time_survey$year) -#'ggplot(us_time_survey, aes(year, sleeping))+ -#' geom_point(alpha = 0.3) + -#' labs( x= "Year", -#' y = "Average hours spent Sleeping", -#' title = "US Average hours spent sleeping, 2009 - 2019") -#' -#' +#' library(ggplot2) +#' us_time_survey$year <- as.factor(us_time_survey$year) +#' ggplot(us_time_survey, aes(year, sleeping)) + +#' geom_point(alpha = 0.3) + +#' labs( +#' x = "Year", +#' y = "Average hours spent Sleeping", +#' title = "US Average hours spent sleeping, 2009 - 2019" +#' ) #' #' @source [US Bureau of Labor Statistics](https://www.bls.gov/tus/) #' @keywords datasets diff --git a/R/data-vote_nsa.R b/R/data-vote_nsa.R index ea67ab1..7a6ed05 100644 --- a/R/data-vote_nsa.R +++ b/R/data-vote_nsa.R @@ -19,7 +19,7 @@ #' @references Kravets, D., 2020. Lawmakers Who Upheld NSA Phone Spying Received #' Double The Defense Industry Cash. WIRED. #' Available at \url{https://www.wired.com/2013/07/money-nsa-vote/}. -#' @source \href{https://www.maplight.org/}{MapLight}. +#' @source [MapLight](https://www.maplight.org/). #' Available at \url{http://s3.documentcloud.org/documents/741074/amash-amendment-vote-maplight.pdf}. #' @keywords datasets #' @examples diff --git a/R/data-voter_count.R b/R/data-voter_count.R index c31e762..e9ad0bc 100644 --- a/R/data-voter_count.R +++ b/R/data-voter_count.R @@ -25,6 +25,6 @@ #' x = "Highest Office", #' y = "Total Ballots" #' ) -#' @source \href{http://www.electproject.org/home/voter-turnout/voter-turnout-data}{United States Election Project} +#' @source [United States Election Project](https://www.electproject.org/election-data/voter-turnout-data) #' "voter_count" diff --git a/data-raw/gerrymander/gerrymander-dataprep.R b/data-raw/gerrymander/gerrymander-dataprep.R index 70cf74d..68b3524 100644 --- a/data-raw/gerrymander/gerrymander-dataprep.R +++ b/data-raw/gerrymander/gerrymander-dataprep.R @@ -10,18 +10,20 @@ raw_data <- read_csv(here::here("data-raw/gerrymander/isostat_congress_election_ # Cleaning: ------------------------------------------------------------------ -clean_data <- raw_data |> - clean_names() |> - select(-x2) |> - separate(col = member2016, - into = c("last_name", "first_name"), - sep = ", ") |> +clean_data <- raw_data |> + clean_names() |> + select(-x2) |> + separate( + col = member2016, + into = c("last_name", "first_name"), + sep = ", " + ) |> mutate( party16 = str_extract(party16, "[:alpha:]"), party18 = str_extract(party18, "[:alpha:]"), gerry = factor(gerry, levels = c("low", "mid", "high")) - ) - + ) + gerrymander <- clean_data diff --git a/data-raw/us_time_survey/us_time_survey-dataprep.R b/data-raw/us_time_survey/us_time_survey-dataprep.R index 444222d..c71ed2f 100644 --- a/data-raw/us_time_survey/us_time_survey-dataprep.R +++ b/data-raw/us_time_survey/us_time_survey-dataprep.R @@ -10,4 +10,3 @@ us_time_survey <- read_excel(here::here("data-raw/us_time_survey/AmericanTimeUse # save -------------------------------------------------------------------------- usethis::use_data(us_time_survey, overwrite = TRUE) - diff --git a/man/gerrymander.Rd b/man/gerrymander.Rd index ffbcb30..f3efe9b 100644 --- a/man/gerrymander.Rd +++ b/man/gerrymander.Rd @@ -34,15 +34,15 @@ A dataset on gerrymandering and its influence on House elections. The data set w library(ggplot2) library(dplyr) ggplot(gerrymander |> filter(gerry != "mid"), aes(clinton16, dem16, color = gerry)) + - geom_jitter(height = 0.05, size = 3, shape = 1) + - geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE) + - scale_color_manual(values = c("purple", "orange")) + - labs( - title = "Logistic Regression of 2016 House Elections", - subtitle = "by Congressional District", - x = "Percent of Presidential Vote Won by Clinton", - y = "Seat Won by Democrat Candidate", - color = "Gerrymandering" - ) + geom_jitter(height = 0.05, size = 3, shape = 1) + + geom_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE) + + scale_color_manual(values = c("purple", "orange")) + + labs( + title = "Logistic Regression of 2016 House Elections", + subtitle = "by Congressional District", + x = "Percent of Presidential Vote Won by Clinton", + y = "Seat Won by Democrat Candidate", + color = "Gerrymandering" + ) } \keyword{datasets} diff --git a/man/prez_pwr.Rd b/man/prez_pwr.Rd index 5f77a6f..43a0ff4 100644 --- a/man/prez_pwr.Rd +++ b/man/prez_pwr.Rd @@ -16,8 +16,7 @@ alot about, or is that beyond the president's control?"} } } \source{ -\href{https://www.pewresearch.org/fact-tank/2013/07/25/can-a-president-control-gas-prices-depends-on-when-you-ask/}{Pew Research Center, May 2006 & March 2012}. -@keywords datasets +\href{https://www.pewresearch.org/short-reads/2013/07/25/can-a-president-control-gas-prices-depends-on-when-you-ask/}{Pew Research Center, May 2006 & March 2012}. } \usage{ prez_pwr diff --git a/man/state_stats.Rd b/man/state_stats.Rd index 5454b90..aff9891 100644 --- a/man/state_stats.Rd +++ b/man/state_stats.Rd @@ -38,7 +38,7 @@ not a factor.} \source{ Census Quick Facts (no longer available as of 2020), InfoChimps (also no longer available as of 2020), -\href{https://www-fars.nhtsa.dot.gov/Main/index.aspx}{National Highway Traffic Safety Administration}, +\href{https://www-fars.nhtsa.dot.gov/Main/index.aspx}{National Highway Traffic Safety Administration} ({\code{tr_deaths}, \code{tr_deaths_no_alc}}), \href{https://www.bls.gov/web/laus/laumstrk.htm}{Bureau of Labor Statistics} (\code{unempl}). diff --git a/man/us_crime_rates.Rd b/man/us_crime_rates.Rd index 65faaf8..d9078a2 100644 --- a/man/us_crime_rates.Rd +++ b/man/us_crime_rates.Rd @@ -22,7 +22,7 @@ A data frame with 60 rows and 12 variables. } } \source{ -\href{http://www.disastercenter.com/crime/uscrime.htm}{Disaster Center} +\href{https://www.disastercenter.com/crime/uscrime.htm}{Disaster Center} } \usage{ us_crime_rates diff --git a/man/us_time_survey.Rd b/man/us_time_survey.Rd index 0198c54..c5a7dff 100644 --- a/man/us_time_survey.Rd +++ b/man/us_time_survey.Rd @@ -30,14 +30,14 @@ Average Time Spent on Activities by Americans \examples{ library(ggplot2) -us_time_survey$year <-as.factor(us_time_survey$year) -ggplot(us_time_survey, aes(year, sleeping))+ - geom_point(alpha = 0.3) + - labs( x= "Year", - y = "Average hours spent Sleeping", - title = "US Average hours spent sleeping, 2009 - 2019") - - +us_time_survey$year <- as.factor(us_time_survey$year) +ggplot(us_time_survey, aes(year, sleeping)) + + geom_point(alpha = 0.3) + + labs( + x = "Year", + y = "Average hours spent Sleeping", + title = "US Average hours spent sleeping, 2009 - 2019" + ) } \keyword{datasets} diff --git a/man/voter_count.Rd b/man/voter_count.Rd index 81cd0e6..ac7bab6 100644 --- a/man/voter_count.Rd +++ b/man/voter_count.Rd @@ -17,7 +17,7 @@ A data frame with 936 rows and 7 variables. } } \source{ -\href{http://www.electproject.org/home/voter-turnout/voter-turnout-data}{United States Election Project} +\href{https://www.electproject.org/election-data/voter-turnout-data}{United States Election Project} } \usage{ voter_count