I was wondering if it is possible to simplify the code of the following function (i.e, if the part of the code: d0 = p$d0, d11 = p$d11, d12 = p$d12, k11 = p$k11, k12 = p$k12 can be replaced by some function) as I am just accessing the variables passed to the function trough the list p.
This is the R code of the function:
equation = function(p){
d0 = p$d0
d11 = p$d11
d12 = p$d12
k11 = p$k11
k12 = p$k12
result = d0 + d11*k11 + d12*k12
return(result)
}
equation(list(d0=1,d11=2,d12=3,k11=100,k12=1000))
p$d0 + p$d11*p$k11 + p$d12*p$k12could be the entire body of your function.equation <- function(p) return(with(p, d0 + d11*k11 + d12*k12))