Hi, folks,


######
food=c('fruit','fruit','fruit','drink','drink','drink')
type=c('apple','apple','orange','water','soda','soda')
value=c(2,3,1,5,7,6)
data=data.frame(food,type,value)
share=c((2+3)/(2+3+1),5/6,1/6,5/(5+7+6),13/18,13/18)
market_con=c(rep(0.8333333^2+0.1666667^2,3),rep(0.2777778^2+0.7222222^2,3))
data$market_con=market_con
######

My problem is how to calculate the concentration (market_con) for different
'food' (1st column). For one food, the concentration is defined as the sum
of the squares of share of each type. The concentration is discussed for
different foods separately. So it means for the same food, we have the same
concentration.

As you see in the above codes, I want to get market_concentration
(market_con) for the origianl data which has three columns. The codes show
what market_concentration is, but you can see I do it manually....

Because 'share' is calculated regarding 'type', where market_con is the sum
of the squares of the share for different 'food'.

Any idea? Hopefully I address the problem clearly

Thanks

	[[alternative HTML version deleted]]

