There are two tasks: create a column in the data frame that represents each year, then split the data, apply cumm and recombine. R has many ways to do both parts.
Probably the most readable way to complete the first task is year from the lubridate package.
library(lubridate) df$year <- year(df$date)
Please note that R has many date formats, so check if you are currently POSIXct or Date or chron or zoo or xts or one of the other formats.
Choosing Seb or ddply for the second task is the one I would recommend. For completeness, you can also use tapply or aggregate .
with(df, tapply(giftamt, year, cumsum)) aggregate(giftamt ~ year, df, cumsum)
With the new information you want to change over the years of July 1, update the year column to
df$year <- with(df, year(date) + (month(date) >= 7))
source share