re: [S] delimiting strings

Scott.Chasalow@USERS.PV.WAU.NL
Wed, 21 Oct 1998 14:35:17 +0200


On Wed Oct 21 12:38:00 1998,
"sinclair, andrew (MIP London)" <asinclair@edfman.co.uk> wrote:
>I am in need of a function that reverses what paste() does.
>
>e.g.
>> tmp <- paste( c("Hello", "World", "!!", collapse = " " )
>> tmp
>"Hello World !!"
>
>Now I would like to be able to do :
>
>> delimit(tmp, sep=" ")
>[1] "Hello" "World" "!!"
>
>Surely this function already exists in Splus - I just don't know of it ??
>Or maybe one of you smart guys can write a nice one-liner ?!

Hello,

In S-PLUS 3.3 for Windoze, you can use this handy one-liner:

> unlist(unpaste("Hello World !!", sep = " "))
[1] "Hello" "World" "!!"

I assume unpaste() still is available in 4.0 and 4.5, I don't recall if it is
in UNIX versions. It does not, however, seem to be documented anywhere! Thus
if you plan to use it in a function for general consumption, you probably
should include a copy so it is guaranteed to be available.

You could have found this function with, e.g.

> lapply(search(), objects, pat = "*paste*"),

assuming, of course, you had guessed that "paste" was in the function name.

Cheers,
Scott
=========================================
Scott.Chasalow@users.pv.wau.nl

Wageningen Agricultural University
Laboratory of Plant Breeding
P.O. Box 386
6700 AJ Wageningen
THE NETHERLANDS

http://www.spg.wau.nl/pv/staff/Chasal_S.htm
===========================================
-----------------------------------------------------------------------
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