Reputation: 11
I am a beginner to R and I would really appreciate all help. I have some data, which I cleaned, removed duplicates,etc. Now, I have this data in a csv file, my main issue is that I am not able to convert it into transactions. I am only able to convert them into lists, but not as transactions.
Please let me know how I can change this data to
This data (like as transactions)
Please help, TIA!!
Upvotes: 0
Views: 600
Reputation: 1238
To convert csv file into transaction file use this code. suppose tfile is the name of csv file
colnames = names(tfile)
bas_str = ""
for(row in 1:nrow(x)){
if(row !=1){
bas_str = paste0( bas_str, "\n")}
bas_str = paste0(bas_str,row,",")
for(col in 2:length(colnames)){
if(col != 2){
bas_str = paste0(bas_str,",")}
bas_str = paste0(bas_str,colnames[col],"=",tfile[row,col])}}
Upvotes: 1