Plotting a function curve in R with 2 or more variables

对着背影说爱祢 提交于 2019-12-02 03:02:54

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))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!