Suppose I have a dataframe:
df <- data.frame(
id = 1:10,
name = c(“Bob”, “Ashley”, “James”, “David”, “Jenny”,
“Hans”, “Leo”, “John”, “Emily”, “Lee”),
gender = c(“Male”, “Female”, “Male”, “Male”, “Female”,
“Male”, “Male”, “Male”, “Female”, “Female”))
I don’t want the standard output for this:
df
id name gender
1 1 Bob Male
2 2 Ashley Female
3 3 James Male
4 4 David Male
5 5 Jenny Female
6 6 Hans Male
7 7 Leo Male
8 8 John Male
9 9 Emily Female
10 10 Lee Female
Instead, I want to know which names go with female and which with male:
Female Male
Ashley Bob
Jenny James
Emily David
Lee Hans
Leo
John
There are plenty of functions that return the count of each (how many males, or how many James), but I’ve been unable to figure out how to just get the possible combinations.