I would like to plot the following function, using ggplot2.
change <- function(score, d, k, p) {k*(score - 1/(1+k^(d/p)))}
I would like to see the results as a function of argument d. What's wrong with the following code?
library(ggplot2)
ggp <- ggplot(data.frame(x=c(0:10)), aes(x)) +
stat_function(fun=change, args=list(1, x, 100, 400))
ggp
Pass the arguments as a named list(without x ) works:
ggp <- ggplot(data.frame(x=c(0:10)), aes(x)) +
stat_function(fun=change, args=list(score=1, k=100, p=400))
From the help page :
args: list of additional arguments to pass to fun
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.