[R] uneven vector length issue with read.zoo?

Gabor Grothendieck ggrothendieck at gmail.com
Sun May 6 23:44:29 CEST 2012


On Sun, May 6, 2012 at 3:42 PM, knavero <knavero at gmail.com> wrote:
> Right, but it seems to me that the error being the NA's in the index field
> are caused by the longer vector lengths of columns 4 and 5. I would think
> that the EOF in the scanf() (assuming C is used for the source code) would
> be called where the NA's begin in columns 1 and 2 since columns 3:5 are
> nulled out. Does this sound like a possible case?
>
> So, if the read in data only contained columns 1 and 2, it wouldn't even
> look at columns 3:5 and thus, rows 14 and so on wouldn't even be looked at
> and that would be EOF already - resulting in no error.
>

Don't know what "longer vector lengths" refers to but every line in
your pastebin data has 5 fields -- they don't vary.

> range(count.fields(URL, sep = ","))
[1] 5 5

Furthermore, the error message seems pretty clear.  Its saying that
the index has a bad entry and is even telling which row or rows it
occurrs at.

Here is another smaller example where the missing entry in row 3
triggers the same sort of message:

> read.zoo(text = "1,2\n2,3\n,4\n6,7", sep = ",")
Error in read.zoo(text = "1,2\n2,3\n,4\n6,7", sep = ",") :
  index has bad entry at data row 3



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list