[R] Reading data from file made by C fwrite

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Tue Feb 29 20:13:05 CET 2000


Hello!

First, I must also congratulate the R core team with their accomplishment!
I have gotten to like R a lot, and I have recommended it for inclusion in
an "Astronomy for Linux"-distribution which is in use by many professional
astronomers and observatories. 

I'm currently working on importing data from files created by a C program
(that I have not written myself, I have the source code, but I don't know
if the author wants to publish it yet). 

I really don't know much about C, but I can understand that the program
writes to a file using 
fwrite(MAP,sizeof(float),MAP_i*MAP_j,f)
where MAP most probably is a pointer to a two-dimensional array of single
precision floats. This is what I want to read into a matrix in R.

When I look at the files written by this program, it is clear that they
are not on a simple form, less says it is a binary file. However, it
appears to be kind of common, as I have seen other packages (such as IDL)
reading files like this without much ado... :-) So, can I read the data of
these files into R? (If not, I may sit down and try to hack it up myself,
some hints would be greatly appreciated).

BTW, something unrelated, if anybody has a couple of examples of
generating random numbers from distribution functions with a couple of
jumps, they would like to share, I'd be happy (I'm an astronomer with very
little training in statistics, so I'm uncertain whether I've got my code 
right (while it returns the expected results, I have a bad feeling)).

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list