如何在r中查看包中数据集的内容?

如何在r中查看包中数据集的内容?,r,dataset,R,Dataset,我是R方面的新手。我想看看R包中数据集的内容。 比如说 在“阿鲁莱斯”软件包的情况下,我想看看成人数据集的内容 我尝试了以下代码,但不起作用 library("arules") data(Adult) View(Adult) 它不起作用 而且 data(Adult) Adult<-as("Adult",matrix) 数据(成人) 成人使用 成人加载数据(数据(成人))后,您只需编写成人即可查看整个数据集。如果数据集很大,您还可以编写head(成人)或tail(成人),分别查看数据集的

我是R方面的新手。我想看看R包中数据集的内容。 比如说

在“阿鲁莱斯”软件包的情况下,我想看看成人数据集的内容

我尝试了以下代码,但不起作用

library("arules")
data(Adult)
View(Adult)
它不起作用

而且

data(Adult)
Adult<-as("Adult",matrix)
数据(成人)
成人使用


成人加载数据(
数据(成人)
)后,您只需编写
成人
即可查看整个数据集。如果数据集很大,您还可以编写
head(成人)
tail(成人)
,分别查看数据集的前10行或最后10行<代码>摘要(成人)
提供数据集的摘要
str(成人)
显示结构,即以何种格式存储各种条目

成人数据集是arules作者定义的一个特殊数据集

> library("arules")
> data(Adult)
> class(Adult)
[1] "transactions"
attr(,"package")
[1] "arules"
> str(Adult)
Formal class 'transactions' [package "arules"] with 4 slots
  ..@ transactionInfo:'data.frame': 48842 obs. of  1 variable:
  .. ..$ transactionID: Factor w/ 48842 levels "1","10","100",..: 1 11112 22223 33334    43288 44399 45510 46621 47732 2 ...
  ..@ data           :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
  .. .. ..@ i       : int [1:612200] 1 10 25 32 35 50 59 61 63 65 ...
  .. .. ..@ p       : int [1:48843] 0 13 26 39 52 65 78 91 104 117 ...
  .. .. ..@ Dim     : int [1:2] 115 48842
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : NULL
  .. .. .. ..$ : NULL
  .. .. ..@ factors : list()
  ..@ itemInfo       :'data.frame': 115 obs. of  3 variables:
  .. ..$ labels   :Class 'AsIs'  chr [1:115] "age=Young" "age=Middle-aged" "age=Senior"   "age=Old" ...
  .. ..$ variables: Factor w/ 13 levels "age","capital-gain",..: 1 1 1 1 13 13 13 13 13  13 ...
  .. ..$ levels   : Factor w/ 112 levels "10th","11th",..: 111 63 92 69 30 54 65 82 90   91 ...
  ..@ itemsetInfo    :'data.frame': 0 obs. of  0 variables
如果您想查看成人的内容,您可以使用以下内容:

> aa <- Adult@data
> class(aa)
[1] "ngCMatrix"
attr(,"package")
[1] "Matrix"
> str(aa)
Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
  ..@ i       : int [1:612200] 1 10 25 32 35 50 59 61 63 65 ...
  ..@ p       : int [1:48843] 0 13 26 39 52 65 78 91 104 117 ...
  ..@ Dim     : int [1:2] 115 48842
  ..@ Dimnames:List of 2
  .. ..$ : NULL
  .. ..$ : NULL
  ..@ factors : list() 
> dim(aa)
[1]   115 48842
> aa[1:5,1:5]
5 x 5 sparse Matrix of class "ngCMatrix"

[1,] . . . . .
[2,] | . | . |
[3,] . | . | .
[4,] . . . . .
[5,] . . . . .
>aa级(aa)
[1] “ngCMatrix”
属性(,“包”)
[1] “矩阵”
>str(aa)
具有5个插槽的正式类“ngCMatrix”[包“矩阵”]
..@i:int[1:612200]110252355059616365。。。
..@p:int[1:48843]0132695657891104117。。。
..@Dim:int[1:2]115 48842
..@Dimnames:2个列表
.. ..$ : 无效的
.. ..$ : 无效的
..@factors:list()
>dim(aa)
[1]   115 48842
>aa[1:5,1:5]
“ngCMatrix”类的5 x 5稀疏矩阵
[1,] . . . . .
[2,] | . | . |
[3,] . | . | .
[4,] . . . . .
[5,] . . . . .