diff --git a/R/data.R b/R/data.R index 2f852f7..8798544 100644 --- a/R/data.R +++ b/R/data.R @@ -9,6 +9,7 @@ #' \item{value}{Life expectancy, including `NA` values for 9 tracts without data} #' } #' @source [CDC's USALEEP project](https://www.cdc.gov/nchs/nvss/usaleep/usaleep.html), current as of Oct. 2021 +#' @keywords dataset "life_exp" #' 2018 DCWS sample indicators @@ -41,6 +42,7 @@ #' #' @source 2018 DataHaven Community Wellbeing Survey #' @name cws2018 +#' @keywords dataset NULL #' @rdname cws2018 @@ -66,6 +68,7 @@ NULL #' \item{value}{Percentage value} #' } #' @source 2018 DataHaven Community Wellbeing Survey +#' @keywords dataset "self_rated_health" #' 2015–2018 DCWS sample trends @@ -80,6 +83,7 @@ NULL #' \item{value}{Percentage value} #' } #' @source 2015 & 2021 DataHaven Community Wellbeing Survey +#' @keywords dataset "cws_trend" #' Rent and income data @@ -95,4 +99,5 @@ NULL #' \item{income_needed}{Income needed for the median rent to make up no more than 30 percent of a household's income, per HUD housing affordability guidelines. Beyond this, a household is considered cost-burdened.} #' } #' @source US Census Bureau 2019 American Community Survey tables B25119, B25031, and B25042. +#' @keywords dataset "rent_x_income" diff --git a/R/dodge_lbls.R b/R/dodge_lbls.R index 6afe2a5..aca584f 100644 --- a/R/dodge_lbls.R +++ b/R/dodge_lbls.R @@ -53,6 +53,7 @@ #' @rdname dodge_lbls #' @import rlang #' @import dplyr +#' @keywords function dodge_lbls <- function(data, x, value, group, thresh, digits = 2) { id_str <- rlang::as_name(enquo(x)) df_left <- dplyr::select(data, {{ x }}, x1 = {{ group }}, val1 = {{ value }}) diff --git a/R/endpoint_lbls.R b/R/endpoint_lbls.R index f4cbcd5..540fe60 100644 --- a/R/endpoint_lbls.R +++ b/R/endpoint_lbls.R @@ -25,18 +25,21 @@ #' geom_line() + #' geom_point(size = 3) + #' geom_text(aes(label = lbl, hjust = just, x = x)) + -#' scale_x_continuous(expand = expansion(add = c(1, 2))) +#' scale_x_continuous(expand = expansion(add = c(1, 3)), +#' breaks = c(2015, 2021)) #' #' cws_trend %>% #' dplyr::filter(indicator == "local_govt_responsive", category == "Age") %>% #' endpoint_lbls(value = value, x = year, group = group, long_side = "both", -#' fun = percent100, add = 0.1, mult = NULL) %>% +#' fun = percent100, add = 0.4, mult = NULL) %>% #' ggplot(aes(x = year, y = value, color = group)) + #' geom_line() + #' geom_point(size = 3) + #' geom_text(aes(label = lbl, hjust = just, x = x)) + -#' scale_x_continuous(expand = expansion(add = 2)) +#' scale_x_continuous(expand = expansion(add = 3), +#' breaks = c(2015, 2021)) #' @export +#' @keywords function #' @rdname endpoint_lbls endpoint_lbls <- function(data, x, value, group, mult = 0.05, add = NULL, fun = NULL, long_side = c("right", "left", "both", "none")) { long_side <- rlang::arg_match(long_side) diff --git a/R/font_add_weights.R b/R/font_add_weights.R index abced0e..3a122f7 100644 --- a/R/font_add_weights.R +++ b/R/font_add_weights.R @@ -24,6 +24,7 @@ #' strip.text = element_text(family = "Source Sans Pro Semibold")) # 600 #' } #' @export +#' @keywords function #' @seealso sysfonts::font_add_google font_add_weights <- function(name, regular = 400, semibold = 600, bold = 700, black = 900) { wts <- stats::setNames(c(regular, semibold, bold, black), c("regular", "semibold", "bold", "black")) diff --git a/R/number_formats.R b/R/number_formats.R index f895deb..eb13d2d 100644 --- a/R/number_formats.R +++ b/R/number_formats.R @@ -15,6 +15,7 @@ #' #' percent_lt1(c(0.25, 0.251, 0.008)) # outputs "25%", "25%", "<1%" #' @rdname number_formats +#' @keywords function #' @export percent100 <- function(x, ...) { scales::percent(x, accuracy = 1, ...) diff --git a/R/offset_lbls.R b/R/offset_lbls.R index c5d0d7b..2f63586 100644 --- a/R/offset_lbls.R +++ b/R/offset_lbls.R @@ -31,6 +31,7 @@ #' geom_text(aes(y = y, label = lbl, color = is_small, vjust = just), show.legend = FALSE) + #' scale_color_manual(values = c("TRUE" = "gray30", "FALSE" = "white")) #' @rdname offset_lbls +#' @keywords function #' @export offset_lbls <- function(data, value, frac = 0.05, thresh = 0.15, margin = 1.5, fun = NULL, na = "N/A") { if (is.null(fun)) { diff --git a/R/palx.R b/R/palx.R index c1beccf..58e240b 100644 --- a/R/palx.R +++ b/R/palx.R @@ -32,6 +32,7 @@ #' palx("#6c888d") # not too light, but not saturated enough #' palx("#0e91a7") # much better--high saturation, middle lightness #' @source \url{https://github.com/jxnblk/palx} +#' @keywords function #' @seealso [colorspace::lighten()] #' @export palx <- function(color, n_hues = 8, n_shades = 9, row = NULL, as_df = FALSE, plot = FALSE, labels = FALSE) { diff --git a/R/round_sum100.R b/R/round_sum100.R index d1aa4d7..8235c26 100644 --- a/R/round_sum100.R +++ b/R/round_sum100.R @@ -15,6 +15,7 @@ #' round_sum100(c(0.24, 0.61, 0.15) * 100) # yay #' round_sum100(c(0.24, 0.6, 0.15) * 100) # sad #' @export +#' @keywords function #' @rdname round_sum100 round_sum100 <- function(x, digits = 0, verbose = FALSE) { if (any(is.na(x))) cli::cli_warn("{.val NA} values in {.arg x} are being dropped.") diff --git a/R/scaffold_project.R b/R/scaffold_project.R index 439457d..6514dd6 100644 --- a/R/scaffold_project.R +++ b/R/scaffold_project.R @@ -45,6 +45,7 @@ #' dryrun = TRUE) #' #' @export +#' @keywords function #' @rdname scaffold_project scaffold_project <- function(dir = ".", input_data = TRUE, diff --git a/R/scale_y_barcontinuous.R b/R/scale_y_barcontinuous.R index 6a5f14a..b4a4cf2 100644 --- a/R/scale_y_barcontinuous.R +++ b/R/scale_y_barcontinuous.R @@ -2,6 +2,7 @@ #' @description This is a light wrapper around `ggplot2::scale_y_continuous` that sets an `expand` argument of `mult = c(0, 0.05)`. The purpose of this is just to align the bases of bars with the x-axis, rather than the default that leaves a gap between bars and the x-axis. #' @param top Numeric, giving the ratio by which to set the upper padding. Defaults 0.05, as is the case for the underlying `ggplot2::scale_y_continuous`. #' @param ... Additional arguments passed on to `ggplot2::scale_y_continuous`. +#' @keywords function #' @export scale_y_barcontinuous <- function(top = 0.05, ...) { ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, top)), ...) diff --git a/R/stack_lbls.R b/R/stack_lbls.R index 3696fdb..489d3b2 100644 --- a/R/stack_lbls.R +++ b/R/stack_lbls.R @@ -55,6 +55,7 @@ #' scale_x_discrete(expand = expansion(add = c(0.8, 1.5))) + #' theme(legend.position = "none") #' @export +#' @keywords function #' @rdname stack_lbls stack_lbls <- function(x, just = 0.5, fill = FALSE) { len_x <- length(x); len_j <- length(just) diff --git a/R/strings.R b/R/strings.R index 96aadd4..24a8e07 100644 --- a/R/strings.R +++ b/R/strings.R @@ -9,6 +9,7 @@ #' title_case("Rates are going up in the area") # This result is technically #' # incorrect--"up" is used as an adverb here, and under APA should be #' # capitalized. Write this one out manually. +#' @keywords function #' @export title_case <- function(x, lower = NULL) { # using APA style guide diff --git a/R/write_plot.R b/R/write_plot.R index d9e5548..bb26799 100644 --- a/R/write_plot.R +++ b/R/write_plot.R @@ -17,6 +17,7 @@ #' @param verbose Logical, whether to print the path to each file after it's written (defaults `TRUE`). #' @param ... Additional arguments to pass on to `ggplot2::ggsave`, which in turn passes them to graphics devices. #' @return Returns nothing. If `verbose = TRUE`, sends a message to the console. +#' @keywords function #' @examples #' \dontrun{ #' library(ggplot2) diff --git a/_pkgdown.yml b/_pkgdown.yml index 753e5d2..e721f20 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -3,9 +3,17 @@ template: bootstrap: 5 bootswatch: lumen bslib: - base_font: {google: "Open Sans"} + base_font: { google: "Open Sans" } code_font_size: "0.75em" home: sidebar: structure: [links, authors, dev] + +reference: + - title: Functions + - contents: + - has_keyword("function") + - title: Sample data + - contents: + - has_keyword("dataset")