Advertisement
elena1234

sapply() with function with two arguments

Apr 12th, 2022
1,489
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.15 KB | None | 1 0
  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
Add Comment
Please, Sign In to add comment
Advertisement