0

Here is a data frame:

     label    category
     orange   fruit
     apple    fruit
     carrot   vegetable
     leek     vegetable
     dog      animal
     cat      animal

I would like to group by category and have a vector or labels for each in a list format:

fruit = c(orange, apple)
vegetable = c(carrot, leek)
animal = c(dog, cat)

What's a good way to do this?

Doug Fir
  • 19,971
  • 47
  • 169
  • 299

0 Answers0