My dataframe is as follows. (similar, there are actually many more rows and columns)
Gender Energetic Weekly_Apple Weekly_Banana
1 Female 3 No Yes
2 Female 3 No Yes
3 Male 5 No Yes
4 Male 2 No No
5 Female 1 No No
I want brief code that outputs the following, based on aggregating the "Yes" responses :
Male Female
Apples 0 0
Bananas 1 2
The number of apples that each gender eats =0. 1 male & 2 females eats apple.
I have tried the following:
count(original_data, c("Gender","Weekly_Apple"))
count(original_data, c("Gender","Weekly_Banana"))
count(original_data, c("Gender","Weekly_Grape"))
count(original_data, c("Gender","Weekly_PineApple"))
aggregate(x = original_data[c("Weekly_Apple",
"Weekly_Banana",
"Weekly_Grape")],
by = original_data[c("Gender")],
FUN = n())