多个令牌的频率对

时间:2019-05-10 14:31:13

标签: r

具有这样的数据框:

df <- data.frame(id = c(1,2,3,4), stocks = c("google stock, yahoo product stock", "google stock, yahoo product stock","yahoo product stock", "google stock"))

如何获取这样的配对频率表:

google stock - yahoo product stock 2
google stock                       1
yahoo product stock                1

1 个答案:

答案 0 :(得分:0)

您想要这样的东西吗?

df <- data.frame(id = c(1,2,3,4), stocks = c("google stock, yahoo product stock",
                                             "google stock, yahoo product stock",
                                             "yahoo product stock",
                                             "google stock"))

table(df$stocks)