On Fri, 11 Jun 2004, Yong Wang wrote:
> I have a quick question follow Jonathan's(as below)
> If I wanna have not only the unique elements in an array but also the
> frequency of each unique elements in the original array, what's the most
> effcient way to get a quick summary list of such frequency corresponding
> to each unique elements?
The answer below suggest ?table, and if you act on that you will see
table() is the answer to your question.
> On Wed, 9 Jun 2004, Spencer Graves wrote:
>
> > ?unique or ?table
> >
> > hope this helps. spencer graves
> >
> > Jonathan Dakin wrote:
> >
> > > 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.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|