tests/testthat/test-manip_correlation.R

# from Traxler et al 2020
fig2 <- manynet::create_explicit(A--B, A--C, B--C, B--D, B--E, B--F, D--E)

test_that("to_correlation works", {
  expect_equal(to_correlation(fig2)["A","F"], 0.5773503, tolerance = 0.005)
  expect_equal(to_correlation(fig2, "diag")["A","F"], 0.5773503, tolerance = 0.005)
  expect_equal(to_correlation(fig2, "recip")["A","F"], 0.6123724, tolerance = 0.005)
  expect_equal(to_correlation(fig2, "all")["A","B"], -0.6324555, tolerance = 0.005)
  expect_equal(to_correlation(fig2, "complex")["A","B"], 0.3162278, tolerance = 0.005)
})

Try the manynet package in your browser

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

manynet documentation built on June 23, 2025, 9:07 a.m.