Attribution function for R