I want to do the following transformation and would like to know if there is a feasible function in R that performs it.
If I have this dataframe:
First <- c("A", "B", "C", "D", "E", "F", "G")
Second <- c("AX", "AX", "AX", "AV", "AV", "AV", "AV")
Count <- c(3, 4, 0, 1, 0, 0, 3)
mytable <- data.frame(First, Second, Count)
| First | Second | Count |
|---|---|---|
| A | AX | 3 |
| B | AX | 4 |
| C | AX | 0 |
| D | AV | 1 |
| E | AV | 0 |
| F | AV | 0 |
| G | AV | 3 |
How can I transform it to the following dataframe:
| First | AX | AV |
|---|---|---|
| A | 3 | 0 |
| B | 4 | 0 |
| C | 0 | 0 |
| D | 0 | 1 |
| E | 0 | 0 |
| F | 0 | 0 |
| G | 0 | 3 |
Thanks in advance!