Advertisement
elena1234

sapply() with function with two arguments

Apr 12th, 2022
648
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. v <- c(1, 2, 3, 4, 5)
  2. add_choice <- function (num, choice) {
  3.   return(num + choice)
  4. }
  5.  
  6. result <- sapply(v , add_choice, choice = 10)
  7. print(result)
  8.  
Advertisement
RAW Paste Data Copied
Advertisement