s-news
[Top] [All Lists]

Re: regMatchPos

To: "Andrew Scott" <ascott@icfrith.com.au>
Subject: Re: regMatchPos
From: David L Lorenz <lorenz@usgs.gov>
Date: Wed, 17 Aug 2005 07:33:53 -0500
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <17ECC4735C623B419672DD87E7539D2B1FC85A@icfmail1.icfrith.com.au>

Andrew,
  I think that you would be better served by using unpaste() and taking the last element generated. The regMatchpos() function expects a vector for x and thus returns only the first occurrence of the table. The function unpaste() does too, and has special rules for a vector.
Dave


"Andrew Scott" <ascott@icfrith.com.au>
Sent by: s-news-owner@lists.biostat.wustl.edu

08/16/2005 09:15 PM

To
<s-news@lists.biostat.wustl.edu>
cc
Subject
[S] regMatchPos





Hi all,

Just trying to use regMatchPos to pick out the 2nd and 3rd occurrences of a space character (" ") from within a string vector so that I can isolate peoples' surnames.

Thus I want to convert:

"Mr John Smith"                                  to                 "Smith"
or
"Mr Smith"                                  to                 "Smith"
or
"Smith"                                                   to                 "Smith"

(In fact, the solution requires the detection of the last occurrence of a space (" ") or the presence of no spaces at all.)

In another example, I have been able to identify the text between a "/" character and the 1st occurrence of a " " using the following:

StPos<-regMatchPos(ProdName,"/")[,1]
EndPos<-regMatchPos(ProdName," ")[,1]
TempBrand<-as.factor(substring(ProdName,StPos+1,EndPos-1))

Thus                  "Computer/Type Model"                 becomes                 "Type"

I've referred to the help screen and S-Plus manual on "regMatchPos" and these refer to "extended tables" and "egrep" but otherwise don't go much further.

Any assistance would be appreciated. (I'm sure this problem has been solved many times before).

Andrew G. Scott, BEc FIAA
Manager - Strategic Analysis and Product Development
IC Frith and Associates





*****************************************************************************************************************************************************
The information contained in this email and any attached files is strictly confidential and may contain legally privileged information.
This email should be read by the intended addressee only. If the recipient of this message is not the intended addressee, please
advise IC Frith & Associates on +61 2 8853 9100 or ascott@icfrith.com.au and promptly delete this email and any attachments.

The intended recipient of this email may only use, reproduce, disclose or distribute the information contained in this email and
any attached files with IC Frith & Associates permission. If you are not the intended addressee, you are strictly prohibited from
using, reproducing, disclosing or distributing the information contained in this email and any attached files.

Although IC Frith & Associates believes this e-mail and any attachments to be free of any virus or other defect which may effect
your computer, it is the responsibility of the recipient to ensure that it is virus free and IC Frith & Associates does not accept any
responsibility for any loss or damage arising in any way from its use.

We maintain a database of clients' contact details. If you do not wish to receive electronic messages from us in future please
email icfteam@icfrith.com.au.

Finally, you should be aware IC Frith & Associates reserves the right and intends to intercept and monitor incoming and outgoing
e-mail correspondence, so you should not expect any e-mail communication to be private in nature.

IC Frith & Associates Pty Ltd ABN 48 097 088 287 AFSL No:230625

*****************************************************************************************************************************************************


--------------------------------------------------------------------
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>
  • regMatchPos, Andrew Scott
    • Re: regMatchPos, David L Lorenz <=