My data.frame(Networks)contains the following:
Location <- c("Farm", "Supermarket", "Farm", "Conference",
"Supermarket", "Supermarket")
Instructor <- c("Bob", "Bob", "Louise", "Sally", "Lee", "Jeff")
Operator <- c("Lee", "Lee", "Julie", "Louise", "Bob", "Louise")
Networks <- data.frame(Location, Instructor, Operator, stringsAsFactors=FALSE)
MY QUESTION
I want to add a new column Transactions$Countto a new data.frame file Transactionsthat sums the exchanges between each Instructorand Operatorfor each Location
EXPECTED EXIT
Location <- c("Farm", "Supermarket", "Farm", "Conference", "Supermarket")
Person1 <- c("Bob", "Louise", "Sally", "Jeff")
Person2 < - c("Lee", "Julie", "Louise", "Louise")
Count < - c(1, 2, 1, 1, 1)
Transactions <- data.frame(Location, Person1, Person2, Count,
stringsAsFactors=FALSE)
For example, there would be a total of 2 exchanges between Bob and Lee at the supermarket. It does not matter if one person is an instructor or operator, I am interested in their exchange. The upcoming issue marks two exchanges between Bob and Lee at the supermarket. There is one exchange for every other combination in other places.
WHAT I SAD
I thought it greplmight come in handy, but I want to iterate over 1300 rows of this data, so it can be expensive. Thank.