If you simply write a function, you may get errors that cause "external", so insert text in it first.
fn <- function(i,j){ ... } A <- outer(1:rows, 1:cols, Vectorize(fn))
An example where it will not work without Vectorizing:
fn <- function(i,j){ return(prop.test(c(tables[i,1], tables[j,1]), c(sum(tables[i,]), sum(tables[j,])))$p.value) }
source share