You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To note, we can replicate the example with sweep() and sapply():
sweep(mtcars, 2, sapply(mtcars, mean), `/`)
09/20/2018 EDIT: Thus,
# f = primary function, most likely a binary operator.
# s = summary statistic function
meep <- function(f, s, x, m) sweep(x, m, apply(x, m, s), f)
# Worth noting that ?sweep has an example with apply().
However, the above draft does not solve the multivariate case. Is one even necessary? The point of sweep() is to "sweep out" (i.e. map a function to) the rows or columns by the associated summary statistic--there is not a tertiary consideration. Perhaps the benefit of meep() is the convenience of apply() being written within the function? This benefit comes at the cost of being unable to input a list of non-function elements for "s" as with sweep().
Use sweep()/apply() combination and rename to "brush" or "mop"--because we are applying the same process to each row or column? [09/21/2018 EDIT: grammar].
The function sweep() is underrated. So, to expand upon its benefits, how should a multivariate version of sweep() resemble?
The text was updated successfully, but these errors were encountered: