I would like to plot a function several times, each time changing a parameter (a constant) in the function. How can i do this?
fun1 <- function(x, b) abs(x^2 - b^2)
plot(fun1(b=0.1),-1, 1)
plot(fun1(b=0.2),-1, 1, add=TRUE)
I would like to plot a function several times, each time changing a parameter (a constant) in the function. How can i do this?
fun1 <- function(x, b) abs(x^2 - b^2)
plot(fun1(b=0.1),-1, 1)
plot(fun1(b=0.2),-1, 1, add=TRUE)
Same approach just generalized in a for-loop:
for (b in c(0.1,0.2))curve(abs(x^2 - b^2),add=TRUE,col='red')
invisible(lapply(...))invisible(lapply(seq(0.1,0.2,0.1), function(b) curve(abs(x^2 - b^2), -1, 1, add = TRUE)))