tests/testthat/test-veg.distance.R

test_that("row and column of results equal to train and test dataset", {
  data("physg")
  physg.train<-physg[1:10,]
  physg.test<-physg[11:30,]
  distance<-veg.distance(physg.test,physg.train,"bray")
  expect_equal(nrow(distance), nrow(physg.test))
  expect_equal(ncol(distance), nrow(physg.train))
})

test_that("error of input datasets", {
  data("physg")
  physg.train<-physg[1:10]
  physg.test<-physg[11:30]
  expect_error(veg.distance(physg.test,physg.train,"bray"))
})

test_that("invalid distance method", {
  data("physg")
  physg.train<-physg[1:10,]
  physg.test<-physg[11:30,]
  expect_error(veg.distance(physg.test,physg.train,"minkowski"))
})

Try the GRNNs package in your browser

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

GRNNs documentation built on Sept. 8, 2021, 5:09 p.m.