R/calc_diff.R

Defines functions calc_diff

#' Add column with the calculated difference between two other columns 
#' 
#' @param df A data frame
#' @param xcol A column of high integers
#' @param ycol A column of low integers
#' @return A column with the difference
#' @export

calc_diff <- function(df, xcol, ycol){
  print(df)
  df_plus <- df %>% 
    mutate(difference = ({{xcol}} - {{ycol}}))
  if (is.data.frame(df) == FALSE){
    return("ERROR - not a dataframe")
  }
  return(df_plus)
}
shawn-pladas/R_package_Pladas documentation built on Dec. 23, 2021, 1:21 a.m.