View source: R/grouped_weighted_mean.R
grouped_weighted_mean | R Documentation |
Fast version of grouped_stats(..., counts = FALSE)
.
Works if there is at most one "by" variable.
grouped_weighted_mean(
data,
x,
w = NULL,
by = NULL,
na.rm = TRUE,
value_name = x
)
data |
A |
x |
Variable name in |
w |
Optional name of the column in |
by |
An optional vector of column names in |
na.rm |
Should missing values in |
value_name |
Name of the resulting column with means. |
A data.frame
with grouped weighted means.
n <- 100
data <- data.frame(
x = rnorm(n),
w = runif(n),
group = factor(sample(1:3, n, TRUE))
)
grouped_weighted_mean(data, x = "x", w = "w", by = "group")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.