SHARE
TWEET

Untitled

a guest Sep 24th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # define a two function argument with default second argument
  2. fn_arg1_less_arg2 <- function(arg1, arg2 = 1) {arg1 - arg2}
  3.  
  4. # result:  0 1 2 3 4
  5. 1:5 %>% fn_two_arg()
  6.  
  7. # result: -1  0  1  2  3
  8. 1:5 %>% fn_two_arg(2)
  9.  
  10. # result: 4 3 2 1 0
  11. 1:5 %>% fn_two_arg(5, .)
RAW Paste Data
Top