calculate_average_S_dxy.R up to date