Let's have some dumb data which say are result I get after I use group by and summarize from dplyr
Name<-rep(c("Pepsi","Cola"),3)
Category<-c("A","A","A","B","B","B")
Value<-1:6
aha<-as.data.frame(cbind(Name,Category,Value))
aha$Value<-as.numeric(as.character(aha$Value))
Our data frame looks like this
Name Category Value
1 Pepsi A 1
2 Cola A 2
3 Pepsi A 3
4 Cola B 4
5 Pepsi B 5
6 Cola B 6
I want to calculate new column where I get value/sum(value) but condition on category.
E.g. for firstrow its 1/6=0,17 because sum of value with A category is 6.
I found how to do it with plyr but it does not get along with dplyr
Help me out please