R/utils.form_args.R

Defines functions get.fun.args form_args

#' @export
form_args <- function(target.fun.name) {
  print("asdfdsa")
  #--------------------------------- GET FULL ARGUMENTS LIST--------------------
  fun.args <- formals(deparse(substitute(target.fun.name)))
  fun.args$... <- NULL
  passed.args <- as.list(match.call(expand.dots = TRUE, envir = sys.frame(2))[-1])
  print(passed.args)

  final.chi.args <- as.list(modifyList(fun.args, passed.args))
  final.chi.args <- final.chi.args[names(final.chi.args) %in% names(fun.args)]
  if (!missing(x)) final.chi.args$x <- x
  if (!missing(y)) final.chi.args$y <- y
  if (is.null(x.name)) final.chi.args$x.name = feR:::.var.name(deparse(substitute(x)))
  if (is.null(y.name)) final.chi.args$y.name =  feR:::.var.name(deparse(substitute(y)))
  #-----------------------------------------------------------------------------
}


#' @export
get.fun.args <- function(passed.args=NULL, FUN = NULL) {
  # print(FUN)
  fun.args <- formals(eval(parse(text=FUN)))
  final.args <- fun.args
  final.args <- passed.args[names(passed.args) %in% names(fun.args)]
  if("..." %in% names(fun.args)) {
    final.args$... <- NULL
    final.args <- append(final.args, passed.args[!(names(passed.args) %in% names(fun.args))])
  }
  final.args <- final.args[names(final.args) %in% names(fun.args)]


}
feranpre/feR documentation built on Nov. 22, 2022, 2:29 a.m.