[Rd] Read a text file into R with .Call()
Ge Tan
184523479 at qq.com
Thu Jun 27 15:18:46 CEST 2013
Hi,
I want to read a text file into R with .Call().
So I define some NEW_CHARACTER() to store the chracters read and use SET_STRING_ELT to fill the elements.
e.g.
PROTECT(qNames = NEW_CHARACTER(10000));
char *foo; // This foo holds the string I want.
while(foo = readLine(FN)){
SET_STRING_ELT(qNames, i, mkChar(foo)));
}
In this way, I can get the desired character from qNames. The only problem is that "mkChar" will make every foo string into a global CHARSXP cache. When I have a huge amount of file to read, the CHARSXP cache use too much memory. I do not know whether there is any other way to SET_STRING_ELT without the mkChar operation. I know I cam refer to the Biostrings pakcage's way of readDNAStringSet, but that is a bit complicated I have not full understood it.
Any help will be appreciated!!
Ge
More information about the R-devel
mailing list