Hi, I would like to integrate over x the following function: f1 <- function(x,int) x^(p+p.int*int) * (1-x)^(q+q.int) where - p, p.int, q, q.int: fixed parameters - int is a binary variable (0 or 1), and specific to a given x, i.e. x=c(0,0.14,0.29,0.32,...,1) int=c(0,0,1,0,1,1,...,0) I would like to calculate the area under the curve between each value of x. I can get this using the integrate function without taking into account the binary variable, i.e. fixing int to 0 or 1: lim = length(x) result.0 <- c() result.1 <- c() for (i in 1:lim-1) { result.0[i] <- integrate(f1,x[i],x[i+1],int=0) result.1[i] <- integrate(f1,x[i],x[i+1],int=1) } Is there a way to take into account the second variable, i.e. for the integration to take into account int for each x ? Thanks in advance. Robert Schneider