I've been using Excel but want to transition over to R but am getting overwhelmed. In excel I use the countifs function a lot to count the instantizes that meet multiple conditions. I have a large CSV with each row containing information about properties (State, pasture area, soy area, corn area, etc.) I want to produce a new table of the counts of properties by state with different conditions. Below is an example of the data I have:
Prop_ID | State | Pasture | Soy | Corn |
---|---|---|---|---|
1 | WI | 20 | 45 | 75 |
2 | MN | 10 | 80 | 122 |
3 | MN | 152 | 0 | 15 |
4 | IL | 0 | 10 | 99 |
5 | IL | 75 | 38 | 0 |
6 | WI | 30 | 45 | 0 |
7 | WI | 68 | 55 | 0 |
I'm looking to produce a new table like this:
State | Cnt by state | Cnt >25 Pasture | Cnt >25 Soy | Cnt>25 Pasture AND Soy |
---|---|---|---|---|
WI | 3 | 2 | 3 | 2 |
MN | 2 | 1 | 1 | 0 |
IL | 2 | 1 | 1 | 1 |
Which is the count per state of properties that have >25 pasture, >25 soy, >25 pasture and soy etc. I'm trying to use dplyr but maybe there is another package that's better for this? So on a side note is there a good class or site that can help me learn the basics of reorganizing and pulling simple statistics out of large tables like I am trying to do here?