I'm sure this is pretty simple, but it's Friday afternoon, and I just
don't see it...
In a data frame with a categorical/character factor, I want to add another
column giving, for each observation, the frequency of that factor level.
An example, where the variable of interest is family:
Hi. Here is one solution:
table(Donner$family)[Donner$family]
Andrija
On Fri, Apr 11, 2014 at 10:40 PM, Michael Friendly frien...@yorku.cawrote:
I'm sure this is pretty simple, but it's Friday afternoon, and I just
don't see it...
In a data frame with a categorical/character factor, I
another:
ave(as.numeric(Donner$family), Donner$family, FUN=length)
On Fri, Apr 11, 2014 at 10:51 PM, Andrija Djurovic djandr...@gmail.comwrote:
Hi. Here is one solution:
table(Donner$family)[Donner$family]
Andrija
On Fri, Apr 11, 2014 at 10:40 PM, Michael Friendly
Bingo! That's exactly the idiom I was looking for.
Thanks, Andrija.
-Michael
On 4/11/2014 4:57 PM, Andrija Djurovic wrote:
another:
ave(as.numeric(Donner$family), Donner$family, FUN=length)
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. Chair,
4 matches
Mail list logo