Hi all,
Following the former post here, I have another question.
I summarized the datasets to the longest continuous days of data, such as df.summary. Each dataset (df1, df2, df3, etc.) has four columns: Year, Month, Day, Value (total/day). How to subset each dataset according to the longest continuous time length, but also a whole calendar year-from January 1st to December 31st. For example, df1 should be subsetted to 1/1/2002 to 12/31/2010. The result will be one year less, but it is the desired output I'd prefer to get. Then I want to calculate the total values in each calendar year. I am wondering how to write it in a loop as there are many datasets. Each dataset has the name df1.xlsx, df2.xlsx, etc. Thanks for your help.
df.summary
ID Length Start End
df1 10 1/10/2001 1/9/2011
df2 4 8/13/2001 8/12/2005
df3 13 3/21/1982 8/5/1995
df1
Year Month Day Value (total/day)
1985 1 1 10
1985 1 2 12
1985 1 5 11.8
1985 1 6 NA
1985 1 7 21
...
2012 12 30 22
2012 12 31 20