zmisc

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

# We need rprojroot to locate other files needed for the Vignette
library(rprojroot)

# Source a few helper/utility functions
source(find_package_root_file("vignettes","utils_knitr.R"))
source(find_package_root_file("vignettes","utils_roxygen.R"))

# Get roxygen blocks, use force to trigger any warnings immediately
blocks <- roxy_get_blocks(find_package_root_file())
blocks <- force(blocks)

r desc::desc_get("Title")

r desc::desc_get("Description")

Installation

You can install the released version of zmisc from CRAN with:

install.packages("zmisc")

You can use pak to install the development version of zmisc from GitHub with:

pak::pak("torfason/zmisc")

Usage

In order to use the package, you generally want to attach it first:

library(zmisc)

Quick and easy value lookups

The functions lookup() and lookuper() are used to look up values from a lookup table, which can be supplied as a vector, a list, or a data.frame. The functions are in some ways similar to the Excel function VLOOKUP(), but are designed to work smoothly in an R workflow, in particular within pipes.

lookup: r roxy_get_section(blocks, "lookup", "title")

r roxy_get_section(blocks, "lookup", "description")

Examples

roxy_get_section(blocks, "lookup", "examples") |> kat_code()

lookuper: r roxy_get_section(blocks, "lookuper", "title")

r roxy_get_section(blocks, "lookuper", "description")

Examples

roxy_get_section(blocks, "lookuper", "examples") |> kat_code()

Safer sampling, sequencing and aggregation

The functions zample(), zeq(), and zingle() are intended to make your code less likely to break in mysterious ways when you encounter unexpected boundary conditions. The zample() and zeq() are almost identical to the sample() and seq() functions, but a bit safer.

zample: r roxy_get_section(blocks, "zample", "title")

r roxy_get_section(blocks, "zample", "description")

Examples

roxy_get_section(blocks, "zample", "examples") |> kat_code()

zeq: r roxy_get_section(blocks, "zeq", "title")

r roxy_get_section(blocks, "zeq", "description")

Examples

roxy_get_section(blocks, "zeq", "examples") |> kat_code()

zingle: r roxy_get_section(blocks, "zingle", "title")

r roxy_get_section(blocks, "zingle", "description")

Examples

roxy_get_section(blocks, "zingle", "examples") |> kat_code()

Getting a better view on variables

The notate() function adds annotations to factor and labelled variables that make it easier to see both values and labels/levels when using the View() function

notate: r roxy_get_section(blocks, "notate", "title")

r roxy_get_section(blocks, "notate", "description")

Examples

roxy_get_section(blocks, "notate", "examples") |> kat_code()


Try the zmisc package in your browser

Any scripts or data that you put into this service are public.

zmisc documentation built on Aug. 22, 2023, 5:07 p.m.