I have a problem with a dataframe with individuals with same ID but different expenses at varius categories like supermarkets, healt, cars, etc. My dataframe is like this:
Base=data.frame(ID=c("CED1","CED2","CED3","CED1","CED1","CED3","CED3","CED2","CED2","CED4"),Value=c(10,20,10,30,50,10,10,20,30,30),Categorie=c("Markets","Markets","Health","Cars","Cars","Health","Cars","Health","Cars","Markets"))
ID Value Categorie
1 CED1 10 Markets
2 CED2 20 Markets
3 CED3 10 Health
4 CED1 30 Cars
5 CED1 50 Cars
6 CED3 10 Health
7 CED3 10 Cars
8 CED2 20 Health
9 CED2 30 Cars
10 CED4 30 Markets
How you can see I have different ID and categories. I would like indicators from this data frame in a new one, and have someone like this:
ID Total.Value Max.Value Min.Value Average.Value %Markets %Health %Cars
CED1 90 50 10 30 11% 0% 89%
CED2 70 30 20 23.33 28.5% 28.5% 42.8%
CED3 30 10 10 10 33.3% 33.3% 33.3%
CED4 30 30 30 30 100% 0% 0%
I am trying to develop this dataframe using plyr but I don't get correct indicators. Thanks for your help.