beginner and while i have attempted to search for an answer to this problem none seem to offer the solution that applys. it might be a simple one but i seem not to hack it. i have this data frame
df <- data.frame(FROM = c("A","A","A","B","D","C","A","D"),
TO = c("B","C","D","A","C","A","B","C"))
I would like to create a new data frame with an extra variable call it "FREQ" with all the unique values of "FROM" and "TO" Such that the new data set Looks like this. I would appreciate some assistance.
df2 <- data.frame(FROM = c("A","A","A","B","D","C"),
TO = c("B","C","D","A","C","A"),
FREQ = c(2,1,1,1,2,1))