I am using a function from a package. When I run the function, it creates 3 different values. Now, I want to run this function for several groups and add the generated values as the unique variable (column) in the original datasets. Is there way to deal with this?
I have written many codes that looks something like this:
df <- df %>%
group_by(group_name) %>%
mutate(new_var = function(var1, var2, var3)
I also tried:
df <- df %>%
group_by(group_name) %>%
mutate(list['a', 'b', 'c']= function(var1, var2, var3)