I have a dataframe ("pollen) that I want to split into several smaller dataframes according to the values in the "Plant" column.
| ID | Bee | Plant | 
|---|---|---|
| 1 | Apis mellifera | Salix caprea | 
| 2 | Osmia cornuta | Prunus cerasifera | 
| 3 | Apis mellifera | Salix caprea | 
| 4 | Apis mellifera | Rosa canina | 
I'm trying to do this:
splt <- split(pollen, pollen$Plant)
pflanzen <- allNames(splt)
for (species in pflanzen) {
      species <- pollen[pollen$Plant==species, ]}
I was hoping to get a bunch of different dataframes named "Salix caprea" and "Prunus cerasifera", etc, but I end up with just one, named "species", that contains the alphabetically last Plant. I thought the "species" in the function would get replaced by the actual species name, but apparently it isnt. What am I doing wrong? Or do you have a smarter way of doing it? Its a bunch of different plant and bee species that I would like to seperate out and I would rather not do it manually.
Thank you!
