I learned in this question calculating double integrals in R quickly how to do double integral.
My problem is when there is one more argument of the function. Please see the example.
z = 2
fun0 = function(x,y) { tan(x+y)*z }
fun01 = integrate(function(y) { 
   sapply(y, function(y) {
      integrate(function(x) fun0(x,y), -.5, y)$value
   })
}, 0, .5)$value
The result is as follows.
 > fun01
[1] 0.1447771
I would like to make this 'fun01' to a function of z.