Skip to content
Prev 295529 / 398502 Next

R does not recognise columns and rows as they are supposed to be

Hello,

There are several things with your code, most of which are not errors.

1. X<-c(364:369) ; Y<-c(82:92 and later c(1:365)
Expressions of the form m:n are integer sequences, the c() is not needed.

2. extract<-vector()
First you create the vector, then keep extending it throughout the loop.
This is much slower.
If you know the final length (and type), create it like this:
extract <- numeric(365)   # or double(365)

3. 'dir1' is not used.

4. Now the readBin instruction:
4.1. 'file' is the name of a function, use, say, 'file1' instead.
4.2. Option 'signed' defaults to TRUE but it's only valid for integer types.

5. And, maybe this is the problem, in R, doubles are 8 bytes, not 4. Get rid
of option 'size', like the help page says,

"If size is specified and not the natural size of the object, each element
of the vector is coerced to an appropriate type before being written or as
it is read."

You are NOT reading doubles.

As for the rest, it seems ok to me. (Keep option 'n' in readBin.)

Hope this helps,

Rui Barradas

Jonsson wrote
--
View this message in context: http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631227.html
Sent from the R help mailing list archive at Nabble.com.