s-news
[Top] [All Lists]

Re: abbreviate long names

To: "Rosenfeld, Simon (NIH/NCI)" <rosenfes@mail.nih.gov>, "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
Subject: Re: abbreviate long names
From: John Fox <jfox@mcmaster.ca>
Date: Sun, 23 Mar 2003 10:25:11 -0500
In-reply-to: <9D7EF737FA4C6F4FBBFC52FC30B836901E539A@nihexchange7.nih.go v>
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
-----------------------------------------------------


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