I am trying to create a basic table with frequencies of a categorical variable (Relationship_type) grouped by another variable (Country), preferably using dplyr library (or anything else that is easier to export as a .csv file than table()).
head(d)
Country Relationship_type
1 Algeria 2
2 Bulgaria 1
3 USA 2
4 Algeria 3
5 Germany 2
6 USA 1
I want this to look like an output from basic table(d$Country, d$Relationship_type) function:
2 3 4
Algeria 141 47 137
Australia 128 27 103
Austria 97 5 17
Belgium 172 16 71
Brazil 104 6 70
CHILE 54 4 46
Tried several combinations of tally(), group_by, count() etc. but can't figure it out.
Could you please help a bit??
All the best, R_beginner