s-news
[Top] [All Lists]

Re: abbreviate long names

To: John Fox <jfox@mcmaster.ca>
Subject: Re: abbreviate long names
From: Spencer Graves <spencer.graves@PDF.COM>
Date: Sun, 23 Mar 2003 07:44:18 -0800
Cc: "Rosenfeld, Simon (NIH/NCI)" <rosenfes@mail.nih.gov>, "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
References: <5.1.0.14.2.20030323102411.01e14aa8@mcmail.cis.mcmaster.ca>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
If you want short names, not necessarily splitting on specific characters like "~", then "abbreviate" might do what you want.

Spencer Graves

John Fox wrote:
Dear Simon,

At 08:40 AM 3/23/2003 -0500, Rosenfeld, Simon (NIH/NCI) wrote:

Dear colleagues:
I have a set of long names structured as follows:
ABCD~~blablablablablablablablabla
EFGHI~~boobooboobooboo
JKL~~foofoofooblablabooboo
MNOPQRST~~oopsoopsoops
,etc.
I need to abbreviate these names in order to obtain
ABCD
EFGHI
JKL
MNOPQRST
etc.
Any suggestions?


You can use regexpr and substring; for example:

 > name <- "ABCD~~blablablablablablablablabla"
 > substring(name, 1,  regexpr("~", name) - 1)
[1] "ABCD"
 >

I hope that this helps,
 John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox@mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>