Created
June 22, 2011 17:23
-
-
Save johncolby/1040603 to your computer and use it in GitHub Desktop.
An example showing how to obtain the mean for each subject across multiple observations in a data frame
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
library(plyr) | |
data = arrange(data.frame(ID=1:10, FA=runif(50, 0.2, 0.8)), ID) | |
ddply(data, 'ID', mean) # using plyr library | |
aggregate(data, list(ID=data$ID), mean) # using base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment