[R] Read trajectory file into R

Thomas Lumley tlumley at u.washington.edu
Wed Jul 23 16:25:44 CEST 2003

On Wed, 23 Jul 2003, Karim Elsawy wrote:

> Thanks a lot for your help, actually I do not know the exact file format
> at the moment
> all what I know is :
> "The DCD files (the trajectory files) are single precision binary
> FORTRAN files, so are transportable
> between computer architectures. They are not, unfortunately,
> transportable between big-endian (most workstations) and little endian
> (Intel) architectures "
> is this enough????

Well, that's enough to get the numbers into R.  You then will have to work
out what they mean.

readBin(connection, numeric(), size=4, n=whatever)

will read `whatever' Fortran single precision numbers from `connection'.
If you are doing this on the machine where the file was generated then you
don't need to worry about endianness.  On a different machine (eg moving
from a Sparc to a PC) you may need to add endian="swap".

Look at readBin for more information.


More information about the R-help mailing list