Say I have these data and this function:
a <- data.frame(a= c(1,2,3), b=c(2,3,4))
fun <- function(q,y,z) {
r <- data.frame(a = c(q+y, q, q, y), b= c(q,q,q,z))
r
}
I would like to apply the function to each row individually and create a list column, where each row has its own data frame in this new column.
Here is what I tried, but it gives an error.
b <- a %>% rowwise(a) %>% mutate(list1 = list(fun(a, b, c)))