R/utils.R

# utilities file for package

# make df into returns -------------------------------
make_ret <- function( df ) {

  df %<>% mutate_if(is.numeric, funs(. / lag(.) ) )

  df <- df[2:nrow(df),]
  return(df)
}

# not in function ----------------------
'%!in%' <- function(x,y)!('%in%'(x,y))

# fill in random days that are unpopulated with previous close -----------------
fill_nm <- function( df ) {
  df %<>% mutate_if(
    is.numeric, funs( ifelse( is.na(lag(.)) == FALSE & is.na(.) == TRUE,
                                               lag(.), .)))
}
SmarshMELLOW/financeSMM documentation built on May 16, 2019, 6:41 p.m.