How can I draw a curve for a function like vpd = function(k,D){exp(-k*D)}
in R?
I want a plot of D
vs vpd
(0:1) assuming k<
While Mamoun Benghezal's answer works for functions you define yourself, there may be cases where you want to plot a predefined function that expects more than 1 parameter. In this case, currying is a solution:
library(functional)
k <- 0.05
vpd <- function(k,D){exp(-k*D)}
vpd_given_k <- Curry(vpd, k = 0.05)
curve(vpd_given_k, ylim = c(0, 1),
from = 1, to = 100,
xlab = "D", ylab = paste("vpd | k = ", k))