全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3235 4
2016-05-10
各位大神们,小弟R语言 初学者 在做AR的时候遇到了个问题,想请教下各位。比如我手上有的数据中部分如下
AutomotiveComputersPersonal ElectronicsGardenClothingHealthJewelryHousewares

0

0

0

1

0

0

0

1

1

0

1

1

0

1

0

0

1

1

0

0

0

0

0

1

第一行是项目,下面1代表购买,0代表没有购买,我想要根据这个数据导入R 中做关联分析,可是直接用read.transactions导入的话数据没法做分析会出现以下问题我是需要先把0-1型的数据变成character型的吗?怎么变呢? 在线求,请大神们帮帮我。。。
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2016-5-10 21:30:44
不好意思 代码没显示出来。。

复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-5-10 21:31:59
不好意思,代码没显示出来,这里补上

> catalog<- read.transactions("CatalogCrossSell.csv")
> summary(catalog)
transactions as itemMatrix in sparse format with
201 rows (elements/itemsets/transactions) and
88 columns (items) and a density of 0.01142017

most frequent items:
1,1,1,0,0,1,0,0, 1,1,1,0,0,0,0,1, 0,0,0,1,0,1,0,1, 1,0,0,0,0,1,0,0, 1,1,1,0,0,1,0,1,          (Other)
              16                9                7                7                7              156

element (itemset/transaction) length distribution:
sizes
  1   2
200   1

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  1.000   1.000   1.000   1.005   1.000   2.000

includes extended item information - examples:
            labels
1 0,0,0,0,0,1,0,0,
2 0,0,0,0,1,0,1,0,
3 0,0,0,0,1,0,1,1,
> str(catalog)
Formal class 'transactions' [package "arules"] with 3 slots
  ..@ data       :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
  .. .. ..@ i       : int [1:202] 86 87 7 56 60 54 40 10 69 66 ...
  .. .. ..@ p       : int [1:202] 0 2 3 4 5 6 7 8 9 10 ...
  .. .. ..@ Dim     : int [1:2] 88 201
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. .. ..@ factors : list()
  ..@ itemInfo   :'data.frame':        88 obs. of  1 variable:
  .. ..$ labels: chr [1:88] "0,0,0,0,0,1,0,0," "0,0,0,0,1,0,1,0," "0,0,0,0,1,0,1,1," "0,0,0,0,1,1,0,1," ...
  ..@ itemsetInfo:'data.frame':        0 obs. of  0 variables
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-5-10 21:33:03
不好意思 代码没显示出来 ,这里补上

> catalog<- read.transactions("CatalogCrossSell.csv")
> summary(catalog)
transactions as itemMatrix in sparse format with
201 rows (elements/itemsets/transactions) and
88 columns (items) and a density of 0.01142017

most frequent items:
1,1,1,0,0,1,0,0, 1,1,1,0,0,0,0,1, 0,0,0,1,0,1,0,1, 1,0,0,0,0,1,0,0, 1,1,1,0,0,1,0,1,          (Other)
              16                9                7                7                7              156

element (itemset/transaction) length distribution:
sizes
  1   2
200   1

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  1.000   1.000   1.000   1.005   1.000   2.000

includes extended item information - examples:
            labels
1 0,0,0,0,0,1,0,0,
2 0,0,0,0,1,0,1,0,
3 0,0,0,0,1,0,1,1,
> str(catalog)
Formal class 'transactions' [package "arules"] with 3 slots
  ..@ data       :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
  .. .. ..@ i       : int [1:202] 86 87 7 56 60 54 40 10 69 66 ...
  .. .. ..@ p       : int [1:202] 0 2 3 4 5 6 7 8 9 10 ...
  .. .. ..@ Dim     : int [1:2] 88 201
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. .. ..@ factors : list()
  ..@ itemInfo   :'data.frame':        88 obs. of  1 variable:
  .. ..$ labels: chr [1:88] "0,0,0,0,0,1,0,0," "0,0,0,0,1,0,1,0," "0,0,0,0,1,0,1,1," "0,0,0,0,1,1,0,1," ...
  ..@ itemsetInfo:'data.frame':        0 obs. of  0 variables
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-5-10 21:34:28
不好意思 代码没显示出来 ,这里补上

> catalog<- read.transactions("CatalogCrossSell.csv")
> summary(catalog)
transactions as itemMatrix in sparse format with
201 rows (elements/itemsets/transactions) and
88 columns (items) and a density of 0.01142017

most frequent items:
1,1,1,0,0,1,0,0, 1,1,1,0,0,0,0,1, 0,0,0,1,0,1,0,1, 1,0,0,0,0,1,0,0, 1,1,1,0,0,1,0,1,          (Other)
              16                9                7                7                7              156

element (itemset/transaction) length distribution:
sizes
  1   2
200   1

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  1.000   1.000   1.000   1.005   1.000   2.000

includes extended item information - examples:
            labels
1 0,0,0,0,0,1,0,0,
2 0,0,0,0,1,0,1,0,
3 0,0,0,0,1,0,1,1,
> str(catalog)
Formal class 'transactions' [package "arules"] with 3 slots
  ..@ data       :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
  .. .. ..@ i       : int [1:202] 86 87 7 56 60 54 40 10 69 66 ...
  .. .. ..@ p       : int [1:202] 0 2 3 4 5 6 7 8 9 10 ...
  .. .. ..@ Dim     : int [1:2] 88 201
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. .. ..@ factors : list()
  ..@ itemInfo   :'data.frame':        88 obs. of  1 variable:
  .. ..$ labels: chr [1:88] "0,0,0,0,0,1,0,0," "0,0,0,0,1,0,1,0," "0,0,0,0,1,0,1,1," "0,0,0,0,1,1,0,1," ...
  ..@ itemsetInfo:'data.frame':        0 obs. of  0 variables
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群