s-news
[Top] [All Lists]

strange counting function needed

To: <s-news@lists.biostat.wustl.edu>
Subject: strange counting function needed
From: "Leeds, Mark" <mleeds@mlp.com>
Date: Fri, 27 Aug 2004 21:17:21 -0400
Thread-index: AcSMnMRy11vTSFM3SCK9PT2YD1wQwg==
Thread-topic: strange counting function needed
i played around and i can't figure out the following "
 
i have a vector of strings called temp such as
 
"AAA" "BBB" "AAA" "CCC" "DDD"
 
so temp1 = "AAA" etc.
 
what i want to return is a vector of numbers
representing how many times the string is in the vector
 
so in this case i would want
 
2    1    2   1    1
 
with looping this is not a problem but
i can't figure out how to do it without looping.
 
i thought
 
temp2_sum(temp == ( temp[1:length(temp)] ))
 
might work but it doesn't.
 
 
                                        thanks
<Prev in Thread] Current Thread [Next in Thread>