Created
December 18, 2013 23:01
-
-
Save bryanmayer/8031396 to your computer and use it in GitHub Desktop.
create a column for baseline values in timeseries data. are there better ways?
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) | |
testdata = data.frame( | |
ID = rep(c("A", "B", "C"), each = 6), | |
time = rep(seq(0, 5, 1), 3), | |
output = rnorm(3 * 6) | |
) | |
testdata = merge(testdata, | |
ddply( | |
subset(testdata, time == 0), .(ID), summarize, | |
BaselineValue = output | |
), | |
by = "ID" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment