mydf <- data.frame(d1 = LETTERS[1:10], d2 = letters[11:20]) > str(mydf) 'data.frame': 10 obs. of 2 variables: $ d1: Factor w/ 10 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 $ d2: Factor w/ 10 levels "k","l","m","n",..: 1 2 3 4 5 6 7 8 9 10 >
library(arules) trans1 <- as(mydf, "transactions") > trans1 transactions in sparse format with 10 transactions (rows) and 20 items (columns) > str(trans1) Formal class 'transactions' [package "arules"] with 3 slots ..@ data :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots .. .. ..@ i : int [1:20] 0 10 1 11 2 12 3 13 4 14 ... .. .. ..@ p : int [1:11] 0 2 4 6 8 10 12 14 16 18 ... .. .. ..@ Dim : int [1:2] 20 10 .. .. ..@ Dimnames:List of 2 .. .. .. ..$ : NULL .. .. .. ..$ : NULL .. .. ..@ factors : list() ..@ itemInfo :'data.frame': 20 obs. of 3 variables: .. ..$ labels : chr [1:20] "d1=A" "d1=B" "d1=C" "d1=D" ... .. ..$ variables: Factor w/ 2 levels "d1","d2": 1 1 1 1 1 1 1 1 1 1 ... .. ..$ levels : Factor w/ 20 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 ... ..@ itemsetInfo:'data.frame': 10 obs. of 1 variable: .. ..$ transactionID: chr [1:10] "1" "2" "3" "4" ...> Reference: http://www.inside-r.org/packages/cran/arules/docs/transactionInfo -- Best, GG [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.