I'm pretty new in R. I have a data frame called 'dati' with 2 columns... the 1st column "Date" (are Date values), the 2nd one are "Values" (float values). 'dati' collects 7809 elements, and the "Date" values go from 1995 to 2015.
If I print 'dati' it is something like:
"Date" "Values"
1 1995-01-01 7.987
2 1995-01-02 7.944
3 1995-01-03 7.901
...
313 1995-12-29 5.187
...
3033 2006-06-13 6.567
3034 2006-06-14 6.588
...
7809 2015-12-31 6.998
I would like to get a subset that contains only elements by filtering the Date values: I need to collect in my subset all the records where year is equals to '1995'... that is something like:
"Date" "Values"
1 1995-01-01 7.987
2 1995-01-02 7.944
3 1995-01-03 7.901
...
313 1995-12-29 5.187
Moreover, can you provide me a for loop where you increment the Date filtering value? For example, a for that makes 3 loops... at the 1st loop the filtering year Date value is '1995', at the 2nd one '1996' and at the 3rd one '1997'.
Please note that in both cases the subsets must contain both column values (Date an Numeric).
Thanks