How to use eval Here is an example…


Guinea-Bissau How to use eval()?
Here is an example.

rencontre sexe fontainebleau test.dframe <- data.frame(x = 1:10, y = rnorm(10)) addSmooth <- function(data, smooth = TRUE) { require(ggplot2) p <- "ggplot(data = data, aes(x = x, y = y))" p.line <- "geom_line()" p.smooth <- "stat_smooth()" if (smooth == TRUE) { p.all <- paste(p, p.line, p.smooth, sep = " + ") } else { p.all <- paste(p, p.line, sep = " + ") }. eval(parse(text = p.all)) }   addSmooth(test.dframe, smooth = FALSE)

Created by Pretty R at inside-R.org


Leave a Reply

Your email address will not be published. Required fields are marked *