I've the following table
| Result_Group | Review |
|---|---|
| A | 1 |
| B | 4 |
| A | 1 |
| C | 1 |
| D | 5 |
| D | 4 |
| E | 5 |
| C | 1 |
| C | 2 |
| A | 2 |
| B | 3 |
| E | 2 |
df = structure(list(Result_Group = structure(c(1L, 2L, 1L, 3L, 4L, 4L, 5L, 3L, 3L, 1L, 2L, 5L), .Label = c("A", "B", "C", "D", "E"
), class = "factor"), Review = c(1L, 4L, 1L, 1L, 5L, 4L, 5L, 1L, 2L, 2L, 3L, 2L)),
class = "data.frame", row.names = c(NA, -12L))
Does anyone know how can create a table for the proportion of the review for each group? Currently I'm doing it group by group and it's taking quite a while just to subset the data.
i.e. the table as follows:
| Review | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | 0.67 | 0 | 0.67 | 0 | 0 |
| 2 | 0.33 | 0 | 0.33 | 0 | 0.50 |
| 3 | 0 | 0.50 | 0 | 0 | 0 |
| 4 | 0 | 0.50 | 0 | 0.5 | 0 |
| 5 | 0 | 0 | 0 | 0.5 | 0.50 |
Thanks!
You can do: