0

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)
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.