I have a sample data below
data <- data.frame(yr = c(1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2009, 2010, 2011, 2012),
ntemp =c (11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 12, 23))
When I try running this function, to access the variable inside a ggplot function.
FUN <- function(data, fun.y, yr) {
fun.data <- data
ggplot(fun.data, aes(yr, fun.y)) +
geom_point() +
scale_y_continuous(fun.y)
}
FUN(data, "ntemp", yr)
I get an Error in eval(expr, envir, enclos) : object 'fun.y' not found
How can I solve this?