test/testthat/testrthpdist.R

describe("rthpdist", {
  it("behaves like pdist", {
    x <- matrix(c(-1.9706166, 1.0316509, -0.1309998, -1.2873508, -0.7316184,
                  -0.9186094, -0.1338765, 0.9594529, 1.2891778, -0.8292798),
                nrow = 5)

    y <- matrix(c(-0.74449610, 0.00110422, 1.13936747, -0.12712808, 0.81960904,
                  -0.3202754, 0.2046293, -0.4874097, -0.6733868, 1.5348313),
                nrow = 5)

    pdist <- matrix(c(1.3643221, 1.7859011, 1.4191837, 1.6985378, 0.5091673,
                      2.2692175, 1.0847178, 0.7662964, 1.6841501, 1.2672216,
                      3.1397345, 0.3695789, 1.9254206, 3.0075278, 1.9019631,
                      1.8597268, 1.2782176, 1.6328442, 2.2798631, 0.6242686,
                      3.7154717, 1.6821258, 1.1111784, 2.1212320, 2.8276012),
                    nrow = 5)

    rthval <- rthpdist(x, y)

    expect_equal(rthval, pdist, tolerance = 0.1)
  })
})
matloff/Rth documentation built on May 21, 2019, 12:55 p.m.