Error loading data in R

2

I'm learning to fiddle with R , and I was writing a script and everything was fine I suddenly typed

read.csv2.ffdf(file="DM_ALUNO.csv",sep="|",first.rows=100000) 

I pressed ctrl + r and the error below appeared

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  scan() expected 'a logical', got '84312'

Does anyone know what to do to solve?

    
asked by anonymous 05.02.2016 / 14:33

1 answer

1

Your problem is that the read.csv2 function uses the scan() function, which requires you to define which column classes of the file you are importing. You have two options, the first one, which I recommend, is for you to use another function for reading.

The function I use by default for large files is read_csv() of package ("readr") .

If you want to continue with this function you can define the classes with the argument colClasses=v , which v is a vector with the classes of all the columns of the file you are reading.

Example: if you have 5 columns in your file, the first as text and the other numeric

read.csv2.ffdf(
    file="DM_ALUNO.csv",
    sep="|",
    first.rows=100000,
    colClasses=c("character",rep("numeric",4))        
)     

English question

    
08.03.2016 / 05:05