I have the following data frame in r:
Color Value
Red 1
Red 3
Red 4
Red 7
Blue 2
Blue 5
Green 1
Green 2
Green 3
What I would like to do is combine the values into a list that I can place into an individual cell, pivoted on color. That is, I want a table that looks like this:
Color Value
Red [1,3,4,7]
Blue [2,5]
Green [1,2,3]
I have some success approaching this problem with a for loop, but I'm finding that it is taking considerable time to execute. Is there a more expeditious data wrangling function in the tidyverse that can perform this transformation? I thought the purrr package might contain the answer but am having difficulty navigating.
Thanks!