【发布时间】:2016-02-10 03:27:41
【问题描述】:
我有这样的数据框:
Port Type
1 Port1 ssh
2 Port1 ftp
3 Port2 http
4 Port1 http
5 Port2 ssh
6 Port3 ssh
7 Port3 https
8 Port4 http
9 Port2 ftp
10 Port3 ssh
11 Port3 ftp
12 Port4 ssh
我想要这样的总和:
Port ssh ftp http https
Port1 1 1 1 0
Port2 1 1 1 0
Port3 2 1 0 1
Port4 1 0 0 1
我选择 R 是因为还有一些其他列有数值,我可以很方便地使用 R 来计算平均值/中位数/分位数。我搜索并找到了这个:Sum of rows based on column value,但是那里的代码似乎只适用于数字元素。
非常感谢您的回答。
【问题讨论】:
-
第四行
http应该是1,https应该是0
标签: r