Let's say my dataset looks like this:
data.table(groups = rep(c("A","B"), each=5), time = rep(2011:2015, 2), value = runif(10,95,105))
groups time value
1: A 2011 97.66647
2: A 2012 103.00917
3: A 2013 103.02462
4: A 2014 103.25105
5: A 2015 101.94881
6: B 2011 97.69248
7: B 2012 95.63296
8: B 2013 98.40150
9: B 2014 104.14164
10: B 2015 103.61722
I would like to rebase the value, within each group, by a value corresponding to chosen year (say, 2013). So, for group A I would like to divide each value by 103.02462 (value for 2013), for group B by 98.40150, etc....
All the solutions that I can think of are incredibly complex, it would be great if someboudy would share their ideas