I know a lot has been posted on getting frequency counts based on two columns, and it is working for me in a way - except for the fact that it takes one of my variables and makes those values into row numbers. I'd like to just have 'normal' row numbers and have both variables as features in a dataframe.
Data example looks as follows:
sport cell
football A1
tennis A2
tennis A1
gym A3
What I'd like to achieve is a count of the number of sports per cell:
cell tennis football gym
1 A1 1 1 0
2 A2 1 0 0
3 A3 0 0 1
Using the following code, it makes the cell feature into row names:
data.frame(table(data$cell, data$sport)[,])
tennis football gym
A1 1 1 0
A2 1 0 0
A3 0 0 1
Also, I've tried to assign numbers to each row and table the three features as follows:
data.frame(table(data$cell, data$sport, data$rownumber)[,])
But that just gives me an error.
Any help would be highly appreciated!