使用match.fun
:
library(timeDate) holidays <- c("GoodFriday", "EasterSunday", "EasterMonday") do.call(rbind, lapply(holidays, function(i){ foo <- match.fun(i) data.frame(Holiday = i, Dates = as.Date(foo(2015:2018))) })) # Holiday Dates # 1 GoodFriday 2015-04-03 # 2 GoodFriday 2016-03-25 # 3 GoodFriday 2017-04-14 # 4 GoodFriday 2018-03-30 # 5 EasterSunday 2015-04-05 # 6 EasterSunday 2016-03-27 # 7 EasterSunday 2017-04-16 # 8 EasterSunday 2018-04-01 # 9 EasterMonday 2015-04-06 # 10 EasterMonday 2016-03-28 # 11 EasterMonday 2017-04-17 # 12 EasterMonday 2018-04-02