I am am getting the warning message in the title
number of items read is not a multiple of the number of columns
I have read about this warning message but I still don't figure out why I got it.
Here's my code:
data <- read.csv("C:/Users/mouna/Desktop/Targa Consult/BD.csv", header=TRUE,sep=";")
write.table(data, file ="basket.csv",sep=";",row.names=FALSE,col.names = TRUE)
tr <- read.transactions("basket.csv",format="single",sep=",",cols=c(3,4),rm.duplicates = TRUE)
summary(tr)
library(arules)
rules <- apriori(tr,parameter=list(supp=0.005,conf=0.8))
I got the warning message after running
tr <- read.transactions("basket.csv",format="single",sep=",",cols=c(3,4),rm.duplicates = TRUE)
Therefore after running
rules <- apriori(tr,parameter=list(supp=0.005,conf=0.8))
I got 0 rules.
In case you land here while trying to read a file which has differing number of lines. A post in this mailing list explains how to find which lines are faulty. Let's say for example that you expect 6 columns and that you read.table returns the error message "number of items read is not a multiple of the number of columns"
. You can find out which line is causing the problem by entering:
x <- count.fields("A.txt", sep="\t")
which(x != 6) # print out the lines that are not correct
This example is for tab separated files, use a different separator (sep
) if you have csv files.