The calculation appears to be sum(a)/(sum(a)+sum(b)).
library(dplyr)
library(tidyr)
result <- ( this_df
%>% gather( group, truth, -c(a,b) )
%>% group_by( group, truth )
%>% summarise( calc = sum(a)/(sum(a)+sum(b)) )
%>% as.data.frame
)
-
Hello all,
I've been banging my head over what must be a simple solution. I would
like to apply a function across columns of a dataframe for rows grouped
across different columns. These groups are not exclusive. See below
for an example. Happy to use dplyr, data.table, or whatever. Any
g
2 matches
Mail list logo