#' Execute formula from data frame column
#'
#' @param .formula
#' @param ... unquoted column names supplying arguements to the function
#' defined in \code{.formula}.
#' @return A logical vector.
#' @examples
#' @export
execute_formula <- function(.formula, ...) {
do.call(eval(parse(text = .formula)),
list(...))
}
#' Parse and Evaluates
#' This is intended for use within the with() function.
#' @param .string a character string to be transformed to non-standard evaluation format.
#' @return Evaluates a character string as an argument in the parent environment.
#' @examples
#' @export
parse_eval <- function(.string) {
eval.parent(parse(text = .string))
}
# test.df <- nysdec_wqs %>%
# filter(grepl("exp", narrative)) %>%
# mutate(hardness = 10)
#
#
# test.df %>%
# mutate(test = do.call(eval(parse(text = formula)), list(hardness))) %>%
# pull(test)
#
# fun <- eval(parse(text = test.df$formula))
# fun(10)
# test.df %>%
# group_by(narrative) %>%
# mutate(test = test(formula, hardness)) %>%
# pull(test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.