Title: | A Collection of Nifty Functions and Objects for OJO Analysts |
---|---|
Description: | We find ourselves repeating the same simple tasks or running a series of R commands over and over again. No more! |
Authors: | Brancen Gregory [aut, cre], Andrew Bell [aut] |
Maintainer: | Brancen Gregory <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.3 |
Built: | 2025-02-06 00:15:49 UTC |
Source: | https://github.com/openjusticeok/ojoutils |
Generate descriptive statements about changes between two values.
describe_change( before, after, input_unit, output_unit, template = NULL, direction_phrases = c(increase = "increased by", decrease = "decreased by", none = "remained unchanged"), include_values = FALSE )
describe_change( before, after, input_unit, output_unit, template = NULL, direction_phrases = c(increase = "increased by", decrease = "decreased by", none = "remained unchanged"), include_values = FALSE )
before |
The initial numeric value to compare. For some unit combinations |
after |
The numeric value to compare to the initial value. |
input_unit |
One of "number", "percent", or "ratio". Determines how the |
output_unit |
One of "number", "percent", "times", or "points". "points" may only be used when |
template |
A |
direction_phrases |
A named vector with three items: "increase", "decrease", and "none", used to customize either the default or custom template. |
include_values |
A logical value indicating whether to include |
A string describing the change between two values, optionally including the values themselves.
# Basic usage with defaults describe_change( before = 1, after = 0.5, input_unit = "ratio", output_unit = "percent", ) #> decreased by 50 percent # Using different phrasing for changes describe_change( before = 33, after = 66, input_unit = "percent", output_unit = "percent", direction_phrases = c( increase = "rose by", decrease = "fell by", none = "stagnated" ) ) #> rose by 100 percent # Customizing the template describe_change( before = 10, after = 12, input_unit = "number", output_unit = "number", template = "{direction} {change} people" ) #> increased by 2 people
# Basic usage with defaults describe_change( before = 1, after = 0.5, input_unit = "ratio", output_unit = "percent", ) #> decreased by 50 percent # Using different phrasing for changes describe_change( before = 33, after = 66, input_unit = "percent", output_unit = "percent", direction_phrases = c( increase = "rose by", decrease = "fell by", none = "stagnated" ) ) #> rose by 100 percent # Customizing the template describe_change( before = 10, after = 12, input_unit = "number", output_unit = "number", template = "{direction} {change} people" ) #> increased by 2 people
Takes a path and determines whether it is empty.
dir_empty(path)
dir_empty(path)
path |
A relative or absolute path to the directory to test. |
TRUE
if the directory is empty, otherwise FALSE
.
If the directory doesn't exist, or the string supplied to path
isn't
recognized as a valid path, then the function returns an error.
A thin wrapper around head
to sooth the pain of context switching between R and SQL
limit(x, ...)
limit(x, ...)
x |
The object to limit |
... |
Additional arguments to |
A thin wrapper around head
that allows
limit
to be used in place of head
. This is useful because
sometimes it is hard to context switch between R and SQL. It can be used on lazy data frames since
this package imports dbplyr
.
The limited object
Oklahoma Counties
ojo_counties
ojo_counties
An object of class character
of length 77.
Creates a new R project with a standard directory structure
ojo_create_project( name = NULL, description = NULL, dir = ".", private = TRUE, packages = NULL )
ojo_create_project( name = NULL, description = NULL, dir = ".", private = TRUE, packages = NULL )
To learn more about creating projects, see the vignette:
vignette("project-creation", package = "ojotools")
Parse Oklahoma Counties
ojo_parse_county( county, ..., case = "lower", squish = NULL, suffix = NULL, counties = ojo_counties, .silent = FALSE )
ojo_parse_county( county, ..., case = "lower", squish = NULL, suffix = NULL, counties = ojo_counties, .silent = FALSE )
county |
A string or character vector that represents an Oklahoma county |
... |
Placeholder for future arguments |
case |
The case to format the county string to. One of "lower", "upper", or "title". |
squish |
A boolean indicator of whether to remove whitespace |
suffix |
Specification of a suffix to remove from each item in |
counties |
A vector of valid county names to match on. |
.silent |
A currently unused argument. |
Wrapper for quarto use template
command. Defaults to OJO html template.
ojo_use_template(path, template = "openjusticeok/ojo-report-template")
ojo_use_template(path, template = "openjusticeok/ojo-report-template")
path |
The name of the directory where the template should be added. This should be a string representing an absolute path, or a path relative to the current working directory. |
template |
The name of the Quarto template to use. This should be a string in the format "username/repository". Default is "openjusticeok/ojo-report-template". |
This function does not return a value. If the user chooses not to proceed with the operation, the function exits silently.
## Not run: ojo_use_template(template = "openjusticeok/ojo-report-template", path = "my_directory") ## End(Not run)
## Not run: ojo_use_template(template = "openjusticeok/ojo-report-template", path = "my_directory") ## End(Not run)