-1

I'm trying to import a CSV using read.table. Since specifying colClasses makes it faster, I tried to use it (it works without colCLasses, so I definitely know this is the issue). The following is the error I got:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
scan() expected 'an integer', got 'N44EU'

Now, this might be due to some mismatch in the classes specified, but I used this method to find the classes:

classes <- sapply(table_name,class)

Further, in the read.table function, for the argument colClasses, I inputted classes. This is when I got the error.

Full code:

initial <- read.table("Dognition.csv",header=TRUE, sep=",", quote="",na.strings = "NA")
classes <- sapply(initial,class)
final <- read.table("Dognition.csv",header=TRUE, sep=",", quote="",na.strings = "NA", colClasses= classes)

Why am I getting this error?

Andrie
  • 176,377
  • 47
  • 447
  • 496
SB3891
  • 61
  • 8

1 Answers1

0

Sheesh. The error was that there were some formulae in my worksheet. When I converted the excel into CSV, I forgot to paste these as values. Once I did this and repeated the process, I didn't get the error!Lesson learnt.

SB3891
  • 61
  • 8