[R] splitting very long character string

john seers (IFR) john.seers at bbsrc.ac.uk
Wed Nov 1 17:00:51 CET 2006


Hi Arne

If you are reading in from files and they are just one number per line
it would be more efficient to use scan directly.  ?scan

For example:

> filen<-"C:/temp/tt.txt"
> i<-scan(filen)
Read 5 items
> i
[1]   12345  564376    5674 6356656    5666
> 


 


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
Arne.Muller at sanofi-aventis.com
Sent: 01 November 2006 15:47
To: r-help at stat.math.ethz.ch
Subject: [R] splitting very long character string


Hello,

I've a very long character array (>500k characters) that need to split
by '\n' resulting in an array of about 60k numbers. The help on strsplit
says to use perl=TRUE to get better formance, but still it takes several
minutes to split this string.

The massive string is the return value of a call to xmlElementsByTagName
from the XML library and looks like this:

...
12345
564376
5674
6356656
5666
...

I've to read about a hundred of these files and was wondering whether
there's a more efficient way to turn this string into an array of
numerics. Any ideas?

	thanks a lot for your help
	and kind regards,

	Arne




	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list