[R] a problem with table() and duplicates
Simone Gabbriellini
simone.gabbriellini at gmail.com
Wed Jan 22 17:25:53 CET 2014
that is awesome, thank you Jim!
2014/1/22 jim holtman <jholtman at gmail.com>:
> try:
>
> table(dataframe$religion[!duplicated(dataframe$name)])
>
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
>
> On Wed, Jan 22, 2014 at 11:04 AM, Simone Gabbriellini
> <simone.gabbriellini at gmail.com> wrote:
>> Dear List,
>>
>> I have a data.frame like this:
>>
>> name religion neighbor religion.neighbor
>> pippo a minnie a
>> pluto a mickey a
>> paperino b donald a
>> paperino b minnie b
>>
>> when I table(dataframe$religion) my data.frame, I get
>> a b
>> 2 2
>>
>> of course, "paperino" is cited twice but should be counted once. Is
>> there anything I can do in order to keep the data.frame the way it is
>> but tell R to count values once if they are repeated?
>>
>> the point is that each row represent a relation, thus I cannot simply
>> remove duplicates...
>>
>> any help more than welcome!
>>
>> Best regards,
>> Simone
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
--
-----------------------------------------------------------------
Simone Gabbriellini, PhD
Post-doctoral Researcher
ANR founded research project "DIFFCERAM"
GEMASS, CNRS & Paris-Sorbonne.
mobile: +39 340 39 75 626
email: simone.gabbriellini at cnrs.fr
More information about the R-help
mailing list