Package 'sovatools'

Title: Sovacool's Tools
Description: A collection of useful functions and examples that don't have an obvious home anywhere else. See the website <https://sovacool.dev/sovatools/> for more information, documentation, and examples.
Authors: Kelly Sovacool [aut, cre]
Maintainer: Kelly Sovacool <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2025-03-08 03:46:18 UTC
Source: https://github.com/kelly-sovacool/sovatools

Help Index


Throw an error if required packages are not installed.

Description

Reports which packages need to be installed. See https://stackoverflow.com/questions/15595478/how-to-get-the-name-of-the-calling-function-inside-the-called-routine

Usage

abort_packages_not_installed(...)

Arguments

...

Package name(s) to check

Details

Adapted from mikropml

Author(s)

Kelly Sovacool [email protected]

Examples

abort_packages_not_installed("base")
## Not run: 
your_function <- function() {
  abort_packages_not_installed("not-a-package-name", "dplyr", "non_package")
}
your_function()

## End(Not run)

Get package dependencies as a tibble

Description

Get package dependencies as a tibble

Usage

get_deps_tbl(package)

Arguments

package

name of an R package

Value

a tibble with the package's recursive dependencies

Examples

## Not run: 
get_deps_tbl("mikropml")

## End(Not run)

Get image height in inches given dimensions in pixels and width in inches

Description

Get image height in inches given dimensions in pixels and width in inches

Usage

get_height_inches(width_pixels, height_pixels, width_inches = 6.5)

Author(s)

Kelly Sovacool [email protected]


Get image dimensions in inches from a file path

Description

Get image dimensions in inches from a file path

Usage

get_image_dims(image_path, width_inches = 6.5)

Author(s)

Kelly Sovacool [email protected]


Insert image in markdown

Description

Insert image in markdown

Usage

insert_image_md(image_path, width_inches = 6.5)

Author(s)

Kelly Sovacool [email protected]


Kelly's go-to theme for ggplot2

Description

Uses ggplot2::theme_bw() and removes margins.

Usage

theme_sovacool()

Value

list of ggproto objects

Examples

library(ggplot2)
ggplot(mtcars) +
  aes(x = mpg, y = wt, color = cyl) +
  geom_point() +
  theme_sovacool()