0
votes

I have a data file recording the type of transaction followed by the items in the transaction (in basket format):

type1 | eggs | chocolate | milk
type2 | milk | bread
type1 | savory | tomato
type3 | chicken

I would later want to remove different type values with appearance:

rules = apriori(dataset, parameter = list(support= 0.1, confidence=0.2), appearance = list(none = c("type=type1", "type=type2")

How do I read in the transactions with the type column? The following does not work as I have data in basket format.

dataset = read.transactions('data.csv', sep = '|', cols=c("type","Products"))

1

1 Answers

1
votes

Manual page for ? read.transactions says:

... cols: For the ‘single’ format, ‘cols’ is a numeric or character vector of length two giving the numbers or names of the columns (fields) with the transaction and item ids, respectively. If character, the first line of ‘file’ is assumed to be a header with column names. For the ‘basket’ format, ‘cols’ can be a numeric scalar giving the number of the column (field) with the transaction ids. If ‘cols = NULL’, the data do not contain transaction ids. ...

So this should work for your data:

dataset <- read.transactions('data.csv', sep = '|', cols=1)