Consider the following code
i = 3 j = i i = 4
However i want
i = 3 f <- function(x, j=i) x * j i = 4 f(4)
If you're wondering why I want to do this, you can consider this code - the application is a model with several abbreviations. The diagonals of the transition matrix are the sum of the other decrements in this row. I would like to determine the decrements that I need, than to calculate other functions using these decrements. In this case, I only need uxt01 and uxt10, and from them I want to create the uxt00 and uxt11 functions. I wanted something that scales to higher dimensions.
Qxt <- matrix(c(uxt00=function(t=0,x=0) 0, uxt01=function(t=0,x=0) 0.05, uxt10=function(t=0,x=0) 0.07 uxt11=function(t=0,x=0) 0), 2, 2, byrow=TRUE) Qxt.diag <- function(Qxt) { ndecrements <- length(Qxt[1,]) for(index in seq(1, N, N+1)) {
source share