R Ggplot2 Stat Function With Calculated Argument For Different Data

R Ggplot2 Stat Function With Calculated Argument For Different Data