From ligges at statistik.uni-dortmund.de  Wed May 25 10:16:48 2005
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Wed May 25 10:15:52 2005
Subject: [Rd] Using a C++ library to read a binary file
In-Reply-To: <93DBC212-ABED-42EC-BB80-598D812BF063@mac.com>
References: <93DBC212-ABED-42EC-BB80-598D812BF063@mac.com>
Message-ID: <42943470.40106@statistik.uni-dortmund.de>

Demitri Muna wrote:

> Hello,
> 
> I am trying to use a C++ library I have to read some data into R.  I've 
> gone over the "Writing R Extensions" page and some of the  archives, but 
> am left somewhat confused (and I'm still very new to R!).
> 
> What I want to do is fairly simple. Given some parameters, I'd like  to 
> read a string of numbers from a proprietary binary file into an  array. 
> I have a C++ library that will read anything I need from this  file.
> 
> What is the best way to do this? Can someone give me any pointers to  
> sample code?

You might be able to write a C wrapper around your C++ code and link 
that into R, so R can get the data directly from a .C() call to your 
wrapper function. See Writing R Extensions for details.


> One possibility I've considered is writing a small unix command line  
> program that, given the parameters, will return the string of  numbers. 
> Is there a way to "capture" this from R into an array?

Yes, this way will also work, please read the R Data Import/Export 
manual and ?connection.

Uwe Ligges



> Cheers,
> 
> Demitri
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Using a C++ library to read a binary file
Uwe Ligges