anon_coder
11/6/2018 - 3:14 PM

apply - list not first arg of function

When there are preset function arguments that you don't want to type out again, and the list is not the first argument of the function


myfun <- function(pronoun, verb, y = "swimming"){
  return(paste(pronoun, verb, y))  
}

sapply(c("go", "went", "like"), function(iter) myfun("I", iter))