作者shirley587 ('')
看板R_Language
标题[问题] 用R软体做购物篮分析(关联规则)
时间Sat Jan 25 23:17:45 2014
[问题类型]:
程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
[软体熟悉度]:
新手(没写过程式,R 是我的第一次)
[问题叙述]:
各位前辈们好 我是第一次使用R 之前也没有写程式的经验
要做购物篮分析 使用的是arules这个套件
手上有一个.csv档案 格式如下
ID ItemA ItemB ItemC ItemD
1 1 0 0 1
2 0 1 0 1
3 1 1 1 0
4 1 0 0 1
5 1 1 0 1
......
我主要是参考这篇 以及其他网路相关资料
http://xccds1977.blogspot.tw/2011/08/apriori.html
步骤如下
1.安装用来跑购物篮分析的套件arules
并把.csv档案汇入R
2.想把数据转为合适的格式
输入的程式码如下
data2<-as(test2, "transactions")
输入後显示 no method or default for coercing “data.frame” to “transations”
碰到的问题和这位网友一样
http://cos.name/cn/topic/112247
这位网友後来有找到解决方法
说是要转成矩阵的格式
想请教各位先进
要怎麽样才能转成适合的矩阵格式呢?
(不好意思 因为没有什麽基础 看了很多资料却不知道该怎麽做
只好上来询问 谢谢各位的帮忙)
--
[其它参考资料]:
http://www.dataguru.cn/article-3326-1.html
http://cran.r-project.org/web/packages/arules/vignettes/arules.pdf
http://cos.name/2013/02/association-rules-with-r-and-sas/
http://web.ydu.edu.tw/~alan9956/docu/refer/R07_AssociationRules_northwind.pdf
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.230.222.140
※ 编辑: shirley587 来自: 61.230.222.140 (01/25 23:19)
1F:→ Wush978:as.matrix? 01/25 23:20
2F:→ shirley587:成功了 感谢版主 已经有提取出规则 可以进行後续解释了 01/25 23:27
3F:→ shirley587:真的是非常感谢~ 01/25 23:27