updated with plot for average r