I have a data frame called 'data' that contains multiple columns:
| Grade | EMPID | PayBand |
|---|---|---|
| A | 12345 | 15001-20000 |
| c | 64859 | 30001-35000 |
| A | 61245 | 20001-25000 |
| D | 75134 | 45001-50000 |
| D | 78451 | 40001-45000 |
| C | 31645 | 30001-35000 |
| A | 62513 | 20001-25000 |
| D | 91843 | 25001-30000 |
| D | 91648 | 35001-40000 |
I need R code to create a data frame that counts the number of each Grade within each PayBand that looks like this. E.g:
| PayBand | A | C | D |
|---|---|---|---|
| 15001-20000 | 1 | 0 | 0 |
| 20001-25000 | 2 | 0 | 0 |
| 25001-30000 | 0 | 0 | 1 |
| 30001-35000 | 0 | 2 | 0 |
| 35001-40000 | 0 | 0 | 1 |
| 40001-45000 | 0 | 0 | 1 |
| 45001-50000 | 0 | 0 | 1 |
I am unsure how to create the new dataframe and the new columns that are based off the first dataframe. Any help is much appreciated.