Created
November 10, 2015 09:53
-
-
Save t-student/b93167cf529607038406 to your computer and use it in GitHub Desktop.
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
# > head(df1, 2) | |
# id cartvol0 cartvol1 incr.cart interval diff | |
# 1 1 1.987862 2.023709 Yes 3 0.03584695 | |
# 2 2 1.694808 1.584858 No 2 -0.10995007 | |
df1$diff <- df1$cartvol1 - df1$cartvol0 | |
v <- as.numeric(quantile(df1$cartvol0, c(0.3333, 0.6667))) | |
df1$interval <- as.factor(findInterval(df1$cartvol0, v)+1) | |
ddply(df1, .(interval), summarise, diff.mean = mean(diff, na.rm = T), n = length(diff)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment