search for: sum_plan_a

Displaying 1 result from an estimated 1 matches for "sum_plan_a".

2010 Jun 26
1
All a column to a data frame with a specific condition
...apple','apple','pear','bread') plan_b=c('bread','bread','orange','bread','bread','yogurt') value=1:6 data=data.frame(plan_a,plan_b,value) library(plyr) library(reshape) mm=melt(data, id=c('plan_a','plan_b')) sum_plan_a=cast(mm,plan_a~variable,sum) ### I would like to add a new column to the data.frame named 'data', with the same sum of value for the same type of plan_a ### The result should come up like this: plan_a plan_b value sum_plan_a 1 apple bread 1 8 2 orange bread 2...