From 184523479 at qq.com  Thu Jun 27 15:18:46 2013
From: 184523479 at qq.com (=?utf-8?B?R2UgVGFu?=)
Date: Thu, 27 Jun 2013 21:18:46 +0800
Subject: [Rd] Read a text file into R with .Call()
Message-ID: <tencent_1039840B6669131118B8D10B@qq.com>

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


[Rd] Read a text file into R with .Call()
=?utf-8?B?R2UgVGFu?=