Dear all,

I have a tab-delimited text (.txt) file which I'm trying to read into R. This 
file is of column format - there are in fact 3 columns and 259201 rows 
(including the column headers). I've been using the following commands, but 
receive an error each time which prevents the data from being read in:


> Jan <- read.table("JanuaryAvBurntArea.txt", header=TRUE)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 1 did not have 6 elements


I tried removing the 'header' argument, but receive a similar message:

> Jan <- read.table("JanuaryAvBurntArea.txt")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 2 did not have 6 elements


What's more confusing about this is that I know that none of the lines have 6 
elements! They're not supposed to! Each row only has 3 values (one per column)!

As a final resort I tried 'scan':

 <- scan("JanuaryAvBurntArea.txt")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  scan() expected 'a real', got 'Latitude'

...which is obviously something to do with there being a header as the first 
row, but the 'scan' command doesn't seem to have an equivalent of 'header=TRUE' 
like read.table...?


If anyone is able to shed some light on why I'm receiving these errors, and how 
I can get the data into R, then I'd be very grateful to hear them! I suspect 
I'm doing something very basic which is wrong!

Many thanks,

Steve




_________________________________________________________________
Win New York holidays with Kellogg’s & Live Search

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to