set.seed(8) data <- data.frame(A=rnorm(10), B=rnorm(10)) fun <- function(df,x,y){ require(dplyr) res <- filter(df,A<x,B>y) %>% nrow() return(res) } This work for single values of x and y:
fun(x=1,y=0,df=data) I would like to do use outer() (or similar) to do combinations of an x and y but cannot figure out how to pass the df argument. It seems to be the same issue as in here: Using outer() with a multivariable function. But passing df through ... does not work:
outer(x=c(0,2),y=c(0,2),fun,df=data) What is missing ?
funmust be yourxandyand it must be vectorized with regard to these arguments if you want to useouter.