Course Hero Logo

Iteminfoitemmatrix method returns the whole

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 73 - 76 out of 133 pages.

itemInfo,itemMatrix-method: returns the whole item/column information data.frame in-cluding labels.itemInfo<-,itemMatrix-method: replaces the item/column info by a data.frame.itemsetInfo,itemMatrix-method: returns the item set/row information data.frame.itemsetInfo<-,itemMatrix-method: replaces the item set/row info by a data.frame.dimnames,itemMatrix-method: returns a list with the dimname vectors.dimnames<-,itemMatrix,list-method: replace the dimnames.
74itemMatrix-classSlotsdataa sparse matrix of classngCMatrixrepresenting the itemsets.Note: the matrix is stored forefficiency reasons transposed!.itemInfoa data.frameitemsetInfoa data.frameObjects from the ClassObjects can be created by calls of the formnew("itemMatrix",...). However, most of the timeobjects will be created by coercion from a matrix, list or data.frame.Coercion• as("matrix", "itemMatrix")• as("itemMatrix", "matrix")• as("list", "itemMatrix")• as("itemMatrix", "list")• as("itemMatrix", "ngCMatrix")• as("ngCMatrix", "itemMatrix")Author(s)Michael HahslerSee AlsoOther itemMatrix and transactions functions:abbreviate(),crossTable(),c(),duplicated(),extract,hierarchy,image(),inspect(),is.superset(),itemFrequencyPlot(),itemFrequency(),match(),merge(),random.transactions(),sample(),sets,size(),supportingTransactions(),tidLists-class,transactions-class,unique()Examplesset.seed(1234)## Generate a logical matrix with 5000 random itemsets for 20 itemsm <- matrix(runif(5000 * 20) > 0.8, ncol = 20,dimnames = list(NULL, paste("item", c(1:20), sep = "")))head(m)## Coerce the logical matrix into an itemMatrix objectimatrix <- as(m, "itemMatrix")imatrix## An itemMatrix contains a set of itemsets (each row is an itemset).## The length of the set is the number of rows.length(imatrix)
itemMatrix-class75## The sparese matrix also has regular matrixdimensions.dim(imatrix)nrow(imatrix)ncol(imatrix)## Subsetting: Get first 5 elements (rows) of the itemMatrix. This can be done in## several ways.imatrix[1:5]### get elements 1:5imatrix[1:5, ]### Matrix subsetting for rows 1:5head(imatrix, n = 5)### head()## Get first 5 elements (rows) of the itemMatrix as list.as(imatrix[1:5], "list")## Get first 5 elements (rows) of the itemMatrix as matrix.as(imatrix[1:5], "matrix")## Get first 5 elements (rows) of the itemMatrix as sparse ngCMatrix.## Warning: For efficiency reasons, the ngCMatrix is transposed!as(imatrix[1:5], "ngCMatrix")## Get labels for the first 5 itemsets (first default and then with## custom formating)labels(imatrix[1:5])labels(imatrix[1:5], itemSep = " + ", setStart = "", setEnd = "")## Create itemsets manually from an itemMatrix. Itemsets contain items in the form of## an itemMatrix and additional quality measures (not supplied in the example).is <- new("itemsets", items = imatrix)isinspect(head(is, n = 3))## Create rules manually. I use imatrix[4:6] for the lhs of the rules and## imatrix[1:3] for the rhs. Rhs and lhs cannot share items so I use## itemSetdiff here. I also assign missing values for the quality measures support## and confidence.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 133 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
NoProfessor

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture