knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
utils.add
is an R
package designed to facilitate an eclectic and evolving set of R
operations commonly implemented by the author in the course of scientific research and/or other R
packages. These functions generally fall into one of the following themes:
It is important to emphasise that utils.add
is not a comprehensive package designed to deliver any one of these themes: many R
packages already fill this space. utils.add
simply makes a few eclectic operations that can be loosely grouped into these themes a bit easier in cases where this has proven useful in the course of the author's research.
You can install the development version of utils.add
from GitHub with:
# install the development version from github: devtools::install_github("edwardlavender/utils.add")
Some functions facilitate data extraction. These include:
isnt_na()
-- Extract observations which are not NA;substr_end()
-- Extract the last n letters from a character;pos_first_unique()
-- Extract the first position of each unique element in a vector;left()
and right()
-- Explore the left and right hand side of a dataframe or matrix respectively;around()
-- Extract the rows in a dataframe around specified position(s);sterm()
-- Define mgcv
model smooth term names (e.g. to extract values from mgcv::predict.gam()
);Some functions which facilitate learning from data. These include:
count_if()
-- Count the number of observations which meet a specified condition;basic_stats()
-- Compute basic statistics (e.g. mean
, mode
, etc.) for a sample;seq_range()
-- Generate a sequence between two values; round_range()
-- Round a range down and up at lower/upper limits respectively;clip_within_range()
-- Clip a vector to lie within a range; find_quantile_bin()
-- Find the quantile bin in which an observation belongs;summarise_along_walk()
-- Summarise every n numbers in a vector; est_prop()
-- Estimate proportions ± standard errors;dev_expl()
-- Calculate the % deviance explained by a model;Some functions facilitate data modification. The include:
add_list_null()
-- Add list(NULL)
to a list in replacement of NULL
elements;list_merge()
-- Merge lists, accounting for empty lists;tidy_coef()
-- Tidy a table of coefficients;add_standard_attr()
-- Add standard attributes (such as the source file and the date) to an object;linear()
-- A linear function based on parameters a
and b
;quadratic()
-- A quadratic function based on parameters a
, b
, h
and k
;sigmoid()
-- A (centred) sigmoidal function based on parameters x0
, L
and k
;load_internal_functions()
-- Load internal functions from a package into the global environment;check...()
-- Check arguments supplied via ...
within a function;check_value()
-- Check that the value of an input supplied to a parent function is appropriate;check_class()
-- Check that the class of an inputted object supplied to a parent function is appropriate;check_tz()
-- Check the time zone of an object and, if appropriate and necessary, force UTC;check_names()
-- Check that required names are contained within an object;check_named_list()
-- Check that a list is named; check_length()
-- Check that the length of an object is the required length;utils.add
is a new and 'personal' package at an early stage of evolution. Function names, arguments and availability may change.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.