I have a data set with several thousand observations across time, grouped by subject (example format below)
ID TIME OBS 001 2200 23 001 2400 11 001 3200 10 001 4500 22 003 3900 45 003 5605 32 005 1800 56 005 1900 34 005 2300 23 ... I would like to identify the first time for each subject, and then subtract this value from each subsequent time. However, the number of observations per subject varies widely (from 1 to 20), and the intervals between times varies widely. Is there a package that can help do this, or a loop that can be set up to evaluate ID, then calculate the values? The outcome I would like is presented below. ID TIME OBS 001 0 23 001 200 11 001 1000 10 001 2300 22 003 0 45 003 1705 32 005 0 56 005 100 34 005 500 23 ... Any help appreciated. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.