# Generated by doctest: do not edit by hand
# Please edit file in R/r2.R

test_that("Doctest: r2_exact", {
  # Created from @doctest for `r2_exact`
  # Source file: R/r2.R
  dat <- matrix(c(5, 5, 4, 6, 2, 7, 7, 4), ncol = 2, byrow = TRUE)
  expect_equal(r2_exact(dat, reference = c(0, 0)), tolerance = 1e-09,
  2.59419191919192)
  expect_equal(r2_exact(dat, reference = c(10, 10), maximise = TRUE), tolerance = 1e-09,
  2.51969696969697)
  extdata_path <- system.file(package = "moocore", "extdata")
  dat <- read_datasets(file.path(extdata_path, "example1_dat"))[, 1:2]
  expect_equal(nrow(dat), 65L)
  expect_equal(r2_exact(dat, reference = 0), tolerance = 1e-09, 3865393.49347081)
  dat <- filter_dominated(dat)
  expect_equal(nrow(dat), 9L)
  expect_equal(r2_exact(dat, reference = 0), tolerance = 1e-09, 3865393.49347081)
})

