Skip to content
Prev 68860 / 398506 Next

generalized matrix product ?

On 4/29/05, George_Heine at blm.gov <George_Heine at blm.gov> wrote:
Try this:

inner <- function(a,b,f, ...) {
		f <- match.fun(f)
		apply(b,2,function(x)apply(a,1,function(y)f(x,y, ...)))
}

data(iris); irish <- head(iris)[,-5]  # test data
res <- inner(t(irish), irish, cor, method = "spearman")  # test

res2 <- cor(irish, method = "spearman") # should give same result
identical(res, res2) # TRUE