user3036416 user3036416 - 24 days ago 8
R Question

Spot erroneous row data frame

I have a data frame like this

head(data)
V1 V2 V3 V4 V5 V6 V7
1 458263182005000000 1941 2 14 -73.90 38.60 US009239
2 451063182005000002 1941 2 14 -74.00 36.90 US009239
3 447463182005000000 1941 2 14 -74.00 35.40 US009239
4 443863182105000000 1941 2 15 -74.00 34.00 US009239
5 436663182105000001 1941 2 15 -74.00 32.60 US009239
6 433063182105000000 1941 2 15 -73.80 31.70 US009239


but when I do

data <- read.table("data.dat",header=F,sep=";")


I get this error

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
could not allocate memory (2048 Mb) in C function 'R_AllocStringBuffer'


How can I determine in which row something is going wrong (e.g. the format is different)?

Many thanks

Answer Source

R says can not allocate memory. So you can check how large is the dataset and your computer memory.