[S] RE: unpaste

Mark Bravington FSMG CEFAS (M.V.BRAVINGTON@cefas.co.uk)
Fri, 23 Oct 1998 10:47:57 +0100


Be warned that "unpaste" is pretty slow, at least on my Splus 4.0 / Windows NT setup. It can be quicker to work via "substring", as the following example of tab replacement shows:

test> xx_ 'aa\tb;asdf\tasdf;l\t\t;lkjasdf'
test> rep.tabs1_ function( x) paste( unlist( unpaste( xx, '\t')), collapse=' ')
test> rep.tabs1( xx)
[1] "aa b;asdf asdf;l ;lkjasdf"
test> rep.tabs2_ function( x) { yy_ substring( xx, 1:nchar( xx), 1:nchar( xx)); yy[ yy=='\t']_ ' '; paste( yy, collapse='') }
test> rep.tabs2( xx)
[1] "aa b;asdf asdf;l ;lkjasdf"
test> dos.time( for( i in 1:1000) rep.tabs1( xx))
[1] 18.50999
test> dos.time( for( i in 1:1000) rep.tabs2( xx))
[1] 4.809998
test>

Moral: don't do what I did and rewrite your code to avoid "substring" in favour of "unpaste"!

Mark Bravington
m.v.bravington@cefas.co.uk
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news