tests/testthat/test-top.percent.by.R

testthat::test_path("files", "catch.csv")
testthat::test_path("files", "catch.top.90.hours.csv")

test_that("the right percentage of the dataframe is kept", {
  catch = read.csv("./files/catch.csv", colClasses = c("mmsi" = "character"))
  catch.top.90.fh = read.csv("./files/catch.top.90.hours.csv", colClasses = c("mmsi" = "character"))

  to.test = top.percent.by(catch, 90, "hours")

  sum.to.test = sum(to.test["hours"])

  sum.to.test.against = sum(catch.top.90.fh["hours"])

  expect_equal(sum.to.test, sum.to.test.against)

  expect_equal(summary(to.test), summary(catch.top.90.fh))

})

Try the fishRman package in your browser

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

fishRman documentation built on May 29, 2024, 2:12 a.m.