楼主: asahikawa
13931 11

[问答] 怎么查看内置数据集的向量值和数据呢? [推广有奖]

  • 5关注
  • 0粉丝

高中生

20%

还不是VIP/贵宾

-

威望
0
论坛币
88 个
通用积分
0.2975
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
984 点
帖子
8
精华
0
在线时间
18 小时
注册时间
2012-9-5
最后登录
2020-2-11

楼主
asahikawa 发表于 2015-2-6 13:42:06 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
当我使用内置数据集groceries时,不管怎么写函数,都看不到数据集内容,只能看到概括有多少数据行列。请问怎么才能看到里面的向量和数据呢?


表现如下:


> data(Groceries)
> Groceries
transactions in sparse format with
9835 transactions (rows) and
169 items (columns)
> tail(Groceries)
transactions in sparse format with
6 transactions (rows) and
169 items (columns)
> head(Groceries)
transactions in sparse format with
6 transactions (rows) and
169 items (columns)

二维码

扫码加我 拉你入群

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

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

关键词:数据集 Transactions Transaction Actions columns

hello

沙发
素直に 发表于 2015-2-6 14:05:17
show()   或者建议你使用Rstudio,能直接提取内部的数据集

藤椅
yywan0913 在职认证  发表于 2015-2-6 14:05:20
  1. #向量值
  2. Groceries@data@p
  3. #数据集
  4. Groceries@itemInfo
复制代码
已有 1 人评分经验 收起 理由
李会超 + 20 热心帮助其他会员

总评分: 经验 + 20   查看全部评分

板凳
asahikawa 发表于 2015-2-6 16:27:42
yywan0913 发表于 2015-2-6 14:05
确实可以了,谢谢你!
能否再请教几个我那天
1,您给的这两个函数后缀的含义是什么?
2,为什么有的数据集能直接显示,有的不能呢?

报纸
asahikawa 发表于 2015-2-6 16:34:21
yywan0913 发表于 2015-2-6 14:05
还有个问题,在查看groceries的向量时,里面有labels、level2、level1三列,而数据集内全为数字。
向量与数据之间是如何组合的?
代表的意义是什么呢?
(这个数据集在arules中,我正在学习apriori,请多多指教!)
> Groceries@itemInfo
                       labels                          level2               level1
1                 frankfurter                         sausage     meet and sausage
2                     sausage                         sausage     meet and sausage
3                  liver loaf                         sausage     meet and sausage
4                         ham                         sausage     meet and sausage
5                        meat                         sausage     meet and sausage
6           finished products                         sausage     meet and sausage
7             organic sausage                         sausage     meet and sausage
8                     chicken                         poultry     meet and sausage
9                      turkey                         poultry     meet and sausage
10                       pork                            pork     meet and sausage
11                       beef                            beef     meet and sausage
12             hamburger meat                            beef     meet and sausage
13                       fish                            fish     meet and sausage
14               citrus fruit                           fruit fruit and vegetables
15             tropical fruit                           fruit fruit and vegetables
16                  pip fruit                           fruit fruit and vegetables
17                     grapes                           fruit fruit and vegetables

地板
yywan0913 在职认证  发表于 2015-2-6 16:55:02
asahikawa 发表于 2015-2-6 16:27
确实可以了,谢谢你!
能否再请教几个我那天
1,您给的这两个函数后缀的含义是什么?
  1. typeof(Groceries)
  2. [1] "S4"
复制代码
数据的类型有很多,甚至还有密文形式的,这个属于S4类 类型   @是对象操作符
可以网上搜索下  R S4类面向对象  之类的说明

7
asahikawa 发表于 2015-2-6 17:59:50
yywan0913 发表于 2015-2-6 16:55
数据的类型有很多,甚至还有密文形式的,这个属于S4类 类型   @是对象操作符
可以网上搜索下  R S4类面向 ...
谢谢前辈,我想请教下@data@p得到的数据时怎么看的。
比如list格式的x如下
> x
         consumer  milk  wine   agg apple coffe
1         Jon Dav  TRUE FALSE  TRUE FALSE FALSE
2   Angel William  TRUE FALSE  TRUE  TRUE FALSE
3       Bull Moss  TRUE FALSE FALSE  TRUE  TRUE
4       Dav Jones FALSE  TRUE FALSE FALSE FALSE
5       Jnic Mark  TRUE FALSE  TRUE  TRUE FALSE
6  Cheryl Cushion  TRUE FALSE  TRUE FALSE  TRUE
7      Reuven Ytz  TRUE  TRUE FALSE  TRUE FALSE
8       Greg Knox FALSE  TRUE FALSE  TRUE  TRUE
9     Joe England FALSE FALSE  TRUE FALSE  TRUE
10       Mary Ray  TRUE  TRUE FALSE  TRUE FALSE


转化成s4格式的面向对象x.class<-as(x,"transactions")
然后用@data@p得到的数据如下
> x.class@data@p
[1]  0  3  7 11 13 17 21 25 29 32 36

请问上面这串数字怎么看呢?和list格式的x有什么关系?

谢谢了!再次感谢!

8
asahikawa 发表于 2015-2-6 18:02:17
素直に 发表于 2015-2-6 14:05
show()   或者建议你使用Rstudio,能直接提取内部的数据集
刚才试了下,show()对s4类型的数据集貌似无效,我现在就是用的rstudio,这种类型的数据集是无法看到的,不过还是谢谢你啦!欢迎一起学习讨论!

9
stephensj 发表于 2015-4-1 13:53:06
同学习,希望楼主进一步解答~

10
sanqima 发表于 2015-4-10 21:42:22
yywan0913 发表于 2015-2-6 16:55
数据的类型有很多,甚至还有密文形式的,这个属于S4类 类型   @是对象操作符
可以网上搜索下  R S4类面向 ...
很好的方法:typeof(Grocerices)

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-6 18:32