tests/testthat/test-median.R

library("TreeTools")
test_that("Median is calculated", {
  tenTrees <- as.phylo(1:10, 8L)
  expect_equal(4, median(tenTrees, index = TRUE))
  expect_equal(as.phylo(4, 8), median(tenTrees))
  expect_equal(as.phylo(4, 8), median(tenTrees, breakTies = FALSE))
  expect_equal(as.phylo(3, 8),
               median(tenTrees, Distance = RobinsonFoulds, breakTies = TRUE))
  expect_equal(c(3:5, 7), median(tenTrees, Distance = RobinsonFoulds, 
                                 index = TRUE, breakTies = FALSE))
  expect_equal(as.phylo(c(3:5, 7), 8),
               median(tenTrees, Distance = RobinsonFoulds, index = FALSE, 
                      breakTies = FALSE),
               ignore_attr = TRUE)
  expect_equal(as.phylo(c(3:5, 7), 8),
               median(tenTrees, Distance = RobinsonFoulds, breakTies = FALSE),
               ignore_attr = TRUE)
})

Try the TreeDist package in your browser

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

TreeDist documentation built on Oct. 26, 2023, 1:07 a.m.