Search Results

Search found 1 results on 1 pages for 'kolonel'.

Page 1/1 | 1 

  • apply function using expand.grid in R

    - by kolonel
    I have two vectors x and y. I create a grid using the following function: v = expand.grid(x, y) I have a function defined as follows N <- function(a, b , dat){ m = ncol(Filter(function(z) a*max(z)*min(z) < b , dat[1:ncol(dat)])) return(m) } and then I need to maximize N over a grid of x,y: Maximize <- function(x , y ,dat){ v = as.matrix(expand.grid(x,y)) # Here is where I want to map the values of v and get the maximum element and # get the tuple in v that maximized N temp1 <- max(apply(v , 1 , N(v[[1]] , v[[2]] , dat))) } Thanks

    Read the article

1