[6256] in s-news-athena
Summary:counting reps of x
daemon@ATHENA.MIT.EDU (Bill Shipley)
Wed Jan 25 09:30:02 1995
Date: Wed, 25 Jan 1995 08:45:57 -0500
To: S-news@utstat.toronto.edu
From: bshipley@courrier.usherb.ca (Bill Shipley)
Yesterday I asked for ideas on how to count the number of replicate values
in a vector. For example, given x<-c(1,1,1,2,2,3,3,3), how to quickly
(therefore without looping) get: 3,2,3.
A number of different methods were suggested but (blush) the easiest way is
to use one of two S-PLUS functions; either table(sort(x)) or rle(sort(x)).
I'm sorry to have posted such a simple problem. I assure you that I spent
over an hour searching through the documentation for such a function, but it
never occured to me that functions with names like "table" or "rle" would do
what I wanted. Is this problem with documentation of functions in S-PLUS
simply due to my lack of experience (stupidity?) or is this a general
problem. Perhaps some sort of standardization of function names is needed?
Thanks for your help.
Bill Shipley
Departement de Biologie
Universite de Sherbrooke
Sherbrooke (Quebec)
CANADA J1K 2R1
bshipley@courrier.USherb.ca