I have some data which looks like:
From this I am trying to create a transactions dataset via:
transact <- subset(sales,select = c('product_id','time_id','customer_id')) transact$transaction_id <- paste(as.character(transact$time_id),as.character(transact$customer_id),sep = ' ') transaction.id <- unique(transact$transaction_id) #Create vectors of each transaction: transaction.1 <- subset(transact,transaction_id == transaction.id,select = c('transaction_id','product_id')) transaction.1_transpose <- as.data.frame(t(transaction.1[,2]))
This gives me:
Is this the right approach?
How do I do this for the whole dataset?