Q: Multiple integration in R int5=function(x5) {sapply(x5, function(x5) {
int4=function(x4) {sapply(x4, function(x4) {
int3=function(x3) {sapply(x3, function(x3) {
int2=function(x2) {sapply(x2, function(x2) {
int1=function(x1) x1*sin(x2^2) # <= f(x1,x2,x3,x4,x5) for example
integrate(int1, x2, 1)$value
})
}
integrate(int2, x3, 1)$value
})
}
integrate(int3, x4, 1)$value
})
}
integrate(int4, x5, 1)$value
})
}
integrate(int5, 0, 1)

Dear R helpers
I need to put these R codes for multiple integration above in a function with arguments supplied so that can be called recursively according to how many integrated variables needed instead of repeating this code 
=function(x) {sapply(x, function(x) { ...
f(x1,x2,x3,x4,x5) above can also be product of {(x[i]-mu[i])^k[i]*g(x[i])*(1-G(x[i]))^R[i]} for i=1,...,5 where g and G are functions and mu, k, and R are constants all as arguments supplied to the function written.
