Dear R forum
I have a vector say as given below
df = c(F, C, F, B, D, A, D, D, A, F, D, F, B, C)
I need to find
(1) how many times each element occurs? e.g. in above vector F occurs 4 times,
C occurs 2 times etc.
(2) Depending on the number of occurrences, I need to repeat the element
try this:
df - c(F, C, F, B, D, A, D, D, A, F, D, F, B,
C)
tab - table(df)
tab
rep(names(tab), 100 * tab)
I hope it helps.
Best,
Dimitris
On 3/26/2013 9:12 AM, Katherine Gobin wrote:
Dear R forum
I have a vector say as given below
df = c(F, C, F, B, D, A, D, D, A, F, D, F, B,
Dear Sir,
Thanks a lot for your great help. I couldn't have figured it out.
Thanks again.
Regards
Katherine
--- On Tue, 26/3/13, D. Rizopoulos d.rizopou...@erasmusmc.nl wrote:
From: D. Rizopoulos d.rizopou...@erasmusmc.nl
Subject: Re: [R] Counting various elemnts in a vactor
To: Katherine
, March 26, 2013 4:12 AM
Subject: [R] Counting various elemnts in a vactor
Dear R forum
I have a vector say as given below
df = c(F, C, F, B, D, A, D, D, A, F, D, F, B, C)
I need to find
(1) how many times each element occurs? e.g. in above vector F occurs 4 times,
C occurs 2 times etc.
(2
4 matches
Mail list logo