1 Matching Annotations
- Jan 2019
-
jrnold.github.io jrnold.github.io
-
sum_to_one <- function(x, na.rm = FALSE) { x / sum(x, na.rm = na.rm) }
Since the sum of x is the same across the input, couldn't you make the code less repetitive by assigning it to an intermediate variable?
sum_to_one <- function(x, na.rm = FALSE) { y = sum(x, na.rm = na.rm) x / y }
-