I have a large data frame (n=553), with the Allele column having 3 levels (0,1,2), and the Range Column with 2 levels(Normal and High).
dd <- data.frame(
Allele = c(0, 0, 1, 1, 2, 2),
Range = c("High", "Normal", "High", "Normal", "High", "Normal"),
Frequency = c(1L, 2L, 9L, 7L, 28L, 17L)
)
I want to be able to take the entire data frame and turn it into a 2x3 table where the output would have the Allele columns and the Range as rows
The problem I'm getting is that I want to be able to add all the frequency counts that match the row ie if Allele = 0 and Range = Normal, then add the frequencies together for all matching rows.
It feels like there is a simple solution but I can't seem to think of one. Any help is greatly appreciated