s-news
[Top] [All Lists]

Re: Extracting vector elements

To: <jd@johndakin.demon.co.uk>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Extracting vector elements
From: "Hugh Jones" <Hugh.Jones@dipnr.nsw.gov.au>
Date: Thu, 10 Jun 2004 09:16:44 +1000
Use
 
unique(c(1,2,2,3,3,3,3,3,4))
 
Hugh Jones
Senior Biometrician
Centre for Natural Resources
NSW Depart. Infrastructure, Planning & Natural Resources
P.O. Box 3720, Parramatta NSW 2124
 
Tel:    61-2- 9895 7628
Fax:   61-2- 9895 7867

>>> "Jonathan Dakin" <jd@johndakin.demon.co.uk> 10/06/2004 02:34:25 >>>

Dear S users,

Is there a simple way of reducing a vector to one in which each element is expressed once, no matter how many occurences there are in the original ?

Eg :

1,2,2,3,3,3,3,3,4  ---->   1,2,3,4

I have been using such convoluted means as the intersection with the set of integers, or reducing to factor data and then re-converting.  Clearly there is something I'm missing.  Many thanks.

Jonathan Dakin
Imperial College London

This message is intended for the addressee named and may contain confidential/privileged information. If you are not the intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the individual sender, and are not necessarily the views of the Department.

You should scan any attached files for viruses.

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