balanced | R Documentation |
Makes a function balance the removal of NA
s across multiple input vectors.
balanced(f, ...)
f |
A function. |
... |
Deprecated. Additional arguments to |
A function like f
with a new argument na.rm
. If na.rm = TRUE
then
complete.cases()
is used to remove missing values across all inputs
prior to calling f
.
Other operators:
grouped()
,
quantity_index()
p1 <- price6[[3]]
p0 <- price6[[2]]
q1 <- quantity6[[3]]
q0 <- quantity6[[2]]
# Balance missing values for a Fisher index
fisher <- balanced(fisher_index)
fisher(p1, p0, q1, replace(q0, 3, NA), na.rm = TRUE)
fisher_index(p1[-3], p0[-3], q1[-3], q0[-3])
# Operators can be combined, but some care may be needed
x <- 1:6
w <- c(1:5, NA)
f <- factor(rep(letters[1:2], each = 3))
grouped(\(x, w) balanced(fisher_mean)(x, w, na.rm = TRUE))(x, w, group = f)
balanced(grouped(fisher_mean))(x, w, group = f, na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.