R Error In Trying To Write A Plotting Function In Ggplot2 Stack

R Error In Trying To Write A Plotting Function In Ggplot2 Stack