tests/testthat/test-centerOnGroup.R

context("Center on Group")

test_that("centerOnGroup should return correct values", {
  d.f<-data.frame(g=gl(3,3),x.1=rnorm(9))
  x.means<-aggregate(data.frame(x.1.mean=d.f$x.1),list(g=d.f$g),mean)
  d.f.2<-merge(d.f,x.means)
  centered<-d.f$x.1-d.f.2$x.1.mean
  cof<-centerOnGroup(data.frame(x=d.f$x.1),d.f$g)
  expect_equal(cof$mean.x, expected=d.f.2$x.1.mean)
  expect_equal(cof$centered.x, expected=centered)

})

Try the dominanceanalysis package in your browser

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

dominanceanalysis documentation built on Jan. 13, 2021, 3:47 p.m.