Reputation: 1143
With R, I am reading a simple file such as
data.frame(read.csv2("myFile.csv", header=F, sep="|"), colnames = c("user","product"))
and I get the error
arguments imply differing number of rows: 5462465, 2
When doing
data <- read.csv2(myFile.csv, header=F, sep="|")
colnames(data) <- c("user","product")
Everything is OK. Why?
Upvotes: 0
Views: 241
Reputation: 2136
There is no colnames
argument in data.frame()
: see manual. So here you are adding a column to your data.frame
which name is "colnames" and you try to add 2 rows : "user" and "product". This makes no sense.
I suggest you to use your working alternative that is perfectly fine.
Upvotes: 2