Skip to content

Commit

Permalink
Tweak site reference page
Browse files Browse the repository at this point in the history
  • Loading branch information
camille-s committed Oct 19, 2023
1 parent e88f3d1 commit bb519dd
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 4 deletions.
5 changes: 5 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,6 +42,7 @@
#'
#' @source 2018 DataHaven Community Wellbeing Survey
#' @name cws2018
#' @keywords dataset
NULL

#' @rdname cws2018
Expand All @@ -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
Expand All @@ -80,6 +83,7 @@ NULL
#' \item{value}{Percentage value}
#' }
#' @source 2015 & 2021 DataHaven Community Wellbeing Survey
#' @keywords dataset
"cws_trend"

#' Rent and income data
Expand All @@ -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"
1 change: 1 addition & 0 deletions R/dodge_lbls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})
Expand Down
9 changes: 6 additions & 3 deletions R/endpoint_lbls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions R/font_add_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
1 change: 1 addition & 0 deletions R/number_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down
1 change: 1 addition & 0 deletions R/offset_lbls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions R/palx.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions R/round_sum100.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
1 change: 1 addition & 0 deletions R/scaffold_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#' dryrun = TRUE)
#'
#' @export
#' @keywords function
#' @rdname scaffold_project
scaffold_project <- function(dir = ".",
input_data = TRUE,
Expand Down
1 change: 1 addition & 0 deletions R/scale_y_barcontinuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)), ...)
Expand Down
1 change: 1 addition & 0 deletions R/stack_lbls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions R/strings.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions R/write_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit bb519dd

Please sign in to comment.