I have a data fame with data like the following:
df <- read.table( text = "ID Date Value
001 2012-01-15 8.6
003 2000-05-03 10.1
001 2005-03-30 7.3
1002 2013-07-05 1.4" , h = TRUE , stringsAsFactors = FALSE )
# ID Date Value
#1 1 2012-01-15 8.6
#2 3 2000-05-03 10.1
#3 1 2005-03-30 7.3
#4 1002 2013-07-05 1.4
I am trying to get the initial date per ID and then get the number of months of each subsequent value for that ID. I can get the min date for each ID simply enough using aggregate but I am stumped on how to do the rest.
Any thoughts on how to accomplish this? I am brand new to R so any pointers would be most appreciated.