From: Economics Guy <economics.guy_at_gmail.com>

Date: Sat, 16 Jun 2007 18:55:54 -0400

**INDICES: B
**

[1] 9085

**INDICES: C
**

[1] 9085

R-help_at_stat.math.ethz.ch 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. Received on Sat 16 Jun 2007 - 23:00:27 GMT

Date: Sat, 16 Jun 2007 18:55:54 -0400

Well apparently this has nothing to do with the gini() command.

I cannot get it to work for something as simple as sum()

Here is the little example I am playing with, maybe someone can help me find my error:

a<-c("A","B","C","A","B","C","A","A","C","B")

b<-c(23,6534,456,234,7,567,345,9,565,345)

[1] 9085

[1] 9085

Same problem as before. It is summing over the whole b vector rather than by the groups.

Anybody have any ideas on what I am doing wrong?

Thanks,

EG

On 6/16/07, Economics Guy <economics.guy_at_gmail.com> wrote:

*>
*

> I have a data set that contains income data and a group identifier. Sort

*> of like:
**>
**>
**> DATA
**>
**> Group,Income
**> A,2300
**> B,6776
**> A,6668
**> A,6768
**> B,9879
**> C,5577
**> A,7867
**> (etc),(etc)
**>
**> I am trying to compute the gini coefficient for each group.
**>
**> I have tried the following and none seem to do the trick:
**>
**> 1)
**>
**> attach(DATA)
**>
**> by(DATA, group, function(x) gini(income))
**>
**>
**> 2)
**>
**> attach(data)
**>
**> tapply(income, group, function(x) gini(income))
**>
**> Both of these return the same value for all groups. Like:
**>
**> group: A
**> [1] 0.2422496
**> ------------------------------------------------------------
**> group: B
**> [1] 0.2422496
**> ------------------------------------------------------------
**> group: C
**> [1] 0.2422496
**> ------------------------------------------------------------
**> group: D
**> [1] 0.2422496
**>
**> Any ideas on how I can make this work? I need the fastest way since I am
**> gonna run a monte carlo based on this routine once I get the basics working.
**>
**>
**> Thanks,
**>
**> EG
*

[[alternative HTML version deleted]]

R-help_at_stat.math.ethz.ch 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. Received on Sat 16 Jun 2007 - 23:00:27 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sun 17 Jun 2007 - 02:32:00 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*