# utilities.R
#' "Cat" %contains% "at" returns true
#'
#' @param s String to check
#' @param pattern Grep pattern to check
#' @return A logical
#' @export
`%contains%` = function(s, pattern) grepl(pattern, s)
#' "Cat" %omits% "dog" returns true
#'
#' @param s String to check
#' @param pattern Grep pattern to check
#' @return A logical
#' @export
`%omits%` = function(s, pattern) !grepl(pattern, s)
#' base "head" returning one item'
#'
#' @export
first = function(x) head(x, 1)
#' base "tail" returning one item
#'
#' @export
last = function(x) tail(x, 1)
#' base "min" ignoring nans
#' @export
nanmin = function(x, y) min(x, y, na.rm = TRUE)
#' base "max" ignoring nans
#' @export
nanmax = function(x, y) max(x, y, na.rm = TRUE)
#' base "mean" ignoring nans
#' @export
nanmean = function(x) mean(x, na.rm = TRUE)
#' base "sd" ignoring nans
#' @export
nansd = function(x) sd(x, na.rm = TRUE)
# lets you x %>% p instead of x %>% print
#' @export
p = function(x) print(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.