Use small helper function
Summary
If you are copy pasting code, it can be made into a small helper function. There are many such examples throughout you codebase, these all need to be fixed.
check_associations.r
x.q = apply(data1, 1, function (x)quantile(x, c(0.05, 0.25, 0.5, 0.75, 0.95),
na.rm=TRUE, names=FALSE))
y.q = apply(data2, 1, function (x)quantile(x, c(0.05, 0.25, 0.5, 0.75, 0.95),
na.rm=TRUE, names=FALSE))
eg: modify your function to take in a quantiles vector too, and you can reuse it accross your entire package.
apply_quantile <- function(data, quantiles_vector) {
apply(data, 1,
function (x) quantile(x, quantiles_vector,
na.rm = TRUE, names = FALSE))
}
Goals/sub-features
-
find this replicated code -
replace with helper function