【发布时间】:2015-07-20 22:19:14
【问题描述】:
我有一个data.frame 对象,我通过这种方式将rules 类的对象转换为data.frame:
trx.cpf.rules.df <- as(trx.cpf.rules, "data.frame")
(您可以从here 的结构中构建trx.cpf.rules.df 对象)。
这个数据框的头部是这样的:
> head(trx.cpf.rules.df)
rules support confidence lift
66 {Product_Group_1,Product_Group_49} => {Product_Group_48} 0.1060016 0.7371274 6.683635
12 {Product_Group_48} => {Product_Group_49} 0.1067810 0.9681979 6.386621
68 {Product_Group_1,Product_Group_23} => {Product_Group_49} 0.1079501 0.9052288 5.971252
16 {Product_Group_23} => {Product_Group_49} 0.1098987 0.8392857 5.536265
71 {Product_Group_1,Product_Group_23} => {Product_Group_34} 0.1024942 0.8594771 4.702384
19 {Product_Group_34} => {Product_Group_23} 0.1079501 0.5906183 4.510496
是否有快速方法(专用函数或类似的东西)将每个trx.cpf.rules.df$rules 转换为两个包含relue;s 元素的向量?例如,对于第一行,它将是:
> (lhs.el <- c("Product_Group_1", "Product_Group_49"))
[1] "Product_Group_1" "Product_Group_49"
> (rhs.el <- c("Product_Group_48"))
[1] "Product_Group_48"
【问题讨论】:
标签: regex r dataframe associations arules