I'm just trying to calculate a proportion of positive samples "1" for each year. Group by year, then sum(binom == "1") / nrows(binom).
structure(list(year = c(2012L, 2012L, 2011L, 2012L, 2015L, 2008L,
2013L, 2008L, 2010L, 2018L, 2014L, 2018L, 2012L, 2014L, 2016L,
2010L, 2015L, 2009L, 2012L, 2008L, 2017L, 2014L, 2008L, 2011L,
2013L, 2013L, 2015L, 2010L, 2017L, 2012L), binom = c(0, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0)), class = c("data.table", "data.frame"), row.names = c(NA,
-30L), .internal.selfref = <pointer: 0x0000022eda621ef0>)
I know this isn't difficult but I'm just not seeing something...
bi.count <- wi.hog.test %>% group_by(year) %>% summarise(across(proportion = nrow(binom == "1",) / nrow(binom == "0" | binom == "1",)))