R functions to work interactively with ggplot