Skip to content

Instantly share code, notes, and snippets.

@bryanmayer
Created December 18, 2013 23:01
Show Gist options
  • Save bryanmayer/8031396 to your computer and use it in GitHub Desktop.
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?
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