group_f | R Documentation |
apply a function by group and return results of the same length to the data
group_f(x, group, f, ...)
x |
same as tapply |
group |
a factor |
f |
function to be applied |
... |
optional arguments passed to the function |
set.seed(123)
data <- data.frame(y = 1:10, g = gl(2,5, labels = c("1-5", "6-10")))
data <- data[sample(nrow(data)), ]
data$mean <- with(data, group_f(y, g, mean))
data$min <- with(data, group_f(y, g, min))
data$max <- with(data, group_f(y, g, max))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.