If you use split() %>% map_df()
, does that give you your ideal output?
df %>%
split(.$Stage) %>%
map_df(~ PLPP(., id='id',Stage = 'Stage',period = 'MonthDiff',event = 'Censor'))
I like using using this pattern because I think it give me more freedom in the type of objects you can manipulate.