Calling a function from pmap is throwing an error as arguments are not being passed on their own
Tried creating lists of the parameters but this too has resulted in an error
library(tidyverse)
library(dplyr)
periods <- c(10,11,12)
redemption <- rep(100,3)
firstcallDate <- c("2014-01-01","2015-01-01","2016-01-01")
testdf <- data.frame(redemption, periods, firstcallDate)
testdf$firstcallDate <- as.Date(testdf$firstcallDate)
testdf$CallSch <- NA
CallScheduleGen <- function (redemption,periods,firstcallDate, ...) {
Price <- rep(as.double(redemption),periods)
Date <- seq(firstcallDate, by = "1 month", length = periods)
callSch <- data.frame(Price, Date)
return(callSch)
}
testdf$CallSch <- pmap_dfr(testdf,CallScheduleGen)
I am expecting a dataframe to be created in each of the cells in the testdf dataframe. Pmap appears to pass input arguments to the functions as a list, rather than element-wise.
Can anyone suggest an approach as I need this to be vectorized rather than creating a loop?