0

I have a large CSV file and I want to have a fastest way to read it by keeping only few interesting columns.

I tried :

read.csv(file="Filename.csv", sep=",", colClasses=c("CLE", "Name","date 1","date 2"))

but it show error:

Error in methods::as(data[[i]], colClasses[i]) : no method or default for coercing “character” to “CLE”

what do you recommand?

DD chen
  • 169
  • 11
  • I don't think that is what colClasses does. It as the name suggests gives classes to columns. R has no idea what CLE is and therefore has no idea what method to call. – NelsonGon Oct 23 '19 at 12:14
  • @NelsonGon I was on wrong way then. what do you recommand? – DD chen Oct 23 '19 at 12:15
  • 1
    Just read the file and select the columns later. I don't think there's any speed advantage in skipping some columns at the read step. If you want speed, use `fread` from `data.table`. – NelsonGon Oct 23 '19 at 12:16

0 Answers0