It is relatively easy to collapse data in R using one or more BY variables and a defined function.
attach(mtcars)
aggdata <-aggregate(mtcars, by=list(cyl,vs),
FUN=mean, na.rm=TRUE)
print(aggdata)
detach(mtcars)рд╕рдВрдЪрд╛рд▓рд┐рдд рджреНрд╡рд╛рд░рд╛
When using the aggregate() function, the by variables must be in a list (even if there is only one). The function can be built-in or user provided.
See also:
Going Further
To practice aggregate() and other functions, try the exercises in this manipulating data tutorial.
It is relatively easy to collapse data in R using one or more BY variables and a defined function.
When using the aggregate() function, the by variables must be in a list (even if there is only one). The function can be built-in or user provided.
See also:
Going Further
To practice aggregate() and other functions, try the exercises in this manipulating data tutorial.