[R] transaction object - how to coerce this data

pdb philb at philbrierley.com
Wed Sep 1 06:52:14 CEST 2010


Hi,

I am wanting to look at frequent item sets using the arules package. I need
to transform my data into a "transactions" object. The data I read in from a
file has 2 columns, an ID and an item. How do I convert data like this into
a transactions object?

I've tried 
class? transactions
but it only confuses me.

My data is like this....
 
basketID 	item
1 	bread
1 	cheese
1 	milk
2 	bread
2 	cheese 
2 	eggs
3 	bread
3 	cheese
3 	beer

and from what I gather it should be like this?

 data <- list(
  c("bread","cheese","milk"),
  c("bread","cheese","eggs"),
  c("bread","cheese","beer")
)

so I can use:

t <- as(data, "transactions")

Thanks in advance.

Phil


-- 
View this message in context: http://r.789695.n4.nabble.com/transaction-object-how-to-coerce-this-data-tp2402613p2402613.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list