I have a dataframe in R (p2.df) that has aggregated a range of values into the following (there are many more columns this is just an abridge version):
genre rating cc dd ee
Adventure FAILURE 140393 20865 358806
Adventure SUCCESS 197182 32872 492874
Fiction FAILURE 140043 14833 308602
Fiction SUCCESS 197725 28848 469879
Sci-fi FAILURE 8681 1682 24259
Sci-fi SUCCESS 7439 1647 22661
I want to get the net values of the proportions for each column, which I can get in a spreadsheet but can't in R studio.
The formula in the spreadsheet follows the pattern:
net_cc = (cc(success)/(cc(success)+dd(success)+ee(success)) - (cc(fail)/(cc(fail)+dd(fail)+ee(fail))
What I want to get out in R is this table that I can get from the spreadsheet:
genre net_cc net_dd net_ee
Adventure 0.002801373059 0.005350579467 -0.008151952526
Fiction -0.01825346696 0.009417699223 0.008835767735
Sci-fi -0.01641517271 0.003297091109 0.0131180816
Any ideas how? If it's any use I created the p2.df by summarising a previous table as:
library(dplyr)
p2.df<- s2.df %>% group_by(genre,rating) %>% summarise_all(sum)