【发布时间】:2021-03-14 08:08:27
【问题描述】:
我正在尝试创建一个基本表,其中分类变量 (Relationship_type) 的频率由另一个变量 (Country) 分组,最好使用 dplyr 库(或任何其他比 table() 更容易导出为 .csv 文件的东西)。
head(d)
Country Relationship_type
1 Algeria 2
2 Bulgaria 1
3 USA 2
4 Algeria 3
5 Germany 2
6 USA 1
我希望它看起来像基本 table(d$Country, d$Relationship_type) 函数的输出:
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
尝试了几种tally()、group_by、count()等的组合,但无法弄清楚。
你能帮忙吗?
一切顺利, R_初学者
【问题讨论】: