Reputation: 33
I am very new in R.I want to see the content of data set in r packages. For example
In the case of "arules" package .I want to see the content of dataset Adult.
I tried with following codes.But not working
library("arules")
data(Adult)
View(Adult)
its not working.
and also
data(Adult)
Adult<-as("Adult",matrix)
??
Upvotes: 2
Views: 3999
Reputation: 3710
The dataset Adult is a special dataset defined by the author of 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
If you want to see the content of Adult, you can use this:
> 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,] . . . . .
Upvotes: 0
Reputation: 7755
After loading the data (data(Adult)
) you can just write Adult
to see the entire data set. If the dataset is large, you could also write head(Adult)
or tail(Adult)
to look at the 10 first or last rows of the dataset, respectively. summary(Adult)
gives you a summary of the dataset. str(Adult)
shows the structure, i.e. in what format various entries are stored.
Upvotes: 2