How to plot function with parameter in R -
i plot function several times, each time changing parameter (a constant) in function. how can 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 generalized in for-loop
:
(b in c(0.1,0.2))curve(abs(x^2 - b^2),add=true,col='red')
Comments
Post a Comment