I have a following data frame:
df <- data.frame(Org_name = c("A", "B", "C", "D", "A", "D", "C", "B"),
Symbol = c("F", "P", "X", "F", "F", "O", "O", "P"))
It contains four values of "Org_name" (A, B, C, D) variable associated with one of the four values of "Symbol" variable (F, P, X, O).
I want to count how many of either F, P, X or O from column "Symbol" are associated with A, B, C, or D from column "Orga_name" in the said data frame.
The result should look like this:
df1 <- data.frame(Org_name = c("A", "B", "C", "D"),
F_freq = c("2", "0", "0", "1"),
P_freq = c("0", "2", "0", "0"),
O_freq = c("0", "0", "1", "1"),
X_freq = c("0", "0", "1", "0"))
I am trying to wrap my head around this, but after few hours of attempts I am nowhere near the end result.
Any advice is welcomed.