I have a dataframe as follows:
d
year total file
1999 3931.12000 A
2002 4273.71020 A
2005 4601.41493 A
2008 4101.32100 A
1999 346.82000 B
2002 134.30882 B
2005 130.43038 B
2008 88.27546 B
I want to have difference of total and its minimum in each group determined by file.
I can think of getting the minimum with:
tapply(d$total, d$file, min)
but I can't think of wise way to get the vector with subtracted minimums.