[R] Need help to convert data frame to transaction set.
arun
smartpink111 at yahoo.com
Sun Apr 20 03:43:33 CEST 2014
Hi,
Without a reproducible example using ?dput() or the package name, it is a bit difficult to comment.
Assuming that you used:
library(arules)
data("AdultUCI")
AdultUCI$ID <- 1:nrow(AdultUCI)
lst1 <- split(AdultUCI[,"ID"], AdultUCI[,"marital-status"])
as(lst1, "transactions")
#transactions in sparse format with
# 7 transactions (rows) and
# 48842 items (columns)
A.K.
On Saturday, April 19, 2014 5:01 PM, Sathish Kumar <tellsathish at gmail.com> wrote:
Hi,
To convert coerce the data set to transaction data set I used the code
trans4 <- as(split(a[,"Cust_ID"], a[,"Parts"]), "transactions")
but I am getting the following error-
Error in as(split(a[, "Cust_ID"], a[, "Parts"]), "transactions") : nomethod
or default for coercing “list” to “transactions”
Then I tried first converting the data set to matrix structure using the
code
c_m<-as.matrix(c_df)
c_m
then entered the following code
trans2 <- as(c_m, "transactions")
but got the following error
Error in as(c_m, "transactions") : no method or default for coercing
“matrix” to “transactions”
Please let me know how to correct the problem.
Thanks
Sathish
______________________________________________
R-help at r-project.org mailing list
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.
More information about the R-help
mailing list