tests/dense_vecvec.R

cosine <- function(x, y)
{
  cp <- crossprod(x, y)
  cp / sqrt(crossprod(x) * crossprod(y))
}


x <- rnorm(30)
y <- rnorm(30)

t1 <- as.vector(cosine(x, y))
t2 <- coop::cosine(x, y)
stopifnot(all.equal(t1, t2, check.attributes=FALSE))


t1 <- cor(x, y)
t2 <- coop::pcor(x, y)
stopifnot(all.equal(t1, t2, check.attributes=FALSE))


t1 <- cov(x, y)
t2 <- coop::covar(x, y)
stopifnot(all.equal(t1, t2, check.attributes=FALSE))

Try the coop package in your browser

Any scripts or data that you put into this service are public.

coop documentation built on Sept. 19, 2021, 5:07 p.m.