I am having some trouble restructuring some data into a more digestible format. I have a data frame like this (but with many more rows and columns). The rows are bird species, the columns are forest types:

```
Species Decid Hemlock Mixed Pine Spruce Total
ACFL     0       2     0    2      0     4
AMCR     0       2     0    0      5     7
AMRE    74      18    51   40     43   226
AMRO     3       0     0    3      0     6
BAWW    16      32    27   29     22   126
BBCU     5       2     1    4      5    17

```

What I want to do is write some code in R that will return a data frame that shows only the 5 species that occurred most in each forest type. In other words, go through each column, find the 5 highest values, then put them in a new data frame along with the associated value in the "Species" column I tried a few methods include using head(), sort(), etc. I was thinking I could do a loop, but I cant figure out how to get it. More specifically, I tried to get the loop to iterate through each column but didn't know how. I now know that df$i is not correct and df[[i]] didn't work either. I'm new to loops so maybe I am going about it all wrong.

I'm sure I could get the result I want through some overly convoluted method, but if anyone knows of any quicker methods I would be greatly appreciative.