Created
August 30, 2013 11:47
-
-
Save andilabs/6389071 to your computer and use it in GitHub Desktop.
R Aggregating Data
It is relatively easy to collapse data in R using one or more BY variables and a defined function.
http://www.statmethods.net/management/aggregate.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# aggregate data frame mtcars by cyl and vs, returning means | |
# for numeric variables | |
attach(mtcars) | |
aggdata <-aggregate(mtcars, by=list(cyl,vs), | |
FUN=mean, na.rm=TRUE) | |
print(aggdata) | |
detach(mtcars) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment