tests/testthat/test-average_fre.R

library(fabricated)


test_that("'average_fre()' accurately calculates the average
          frequency for a dataset of 4 numbers", {

            x <- data.frame(obs = c(1.2, 3.0, 3.0, 2.8))
            expect_equal(average_fre(x, obs) %>% dplyr::pull(),
                         1.5)
          })

test_that("'average_fre()' accurately calculates the average
          frequency for a dataset of 10 numbers with multiple
          decimals", {

            x <- data.frame(obs = c(1.2345, 3.405, 3.001, 2.893, 0.0230,
                                    23.001, 3.4089, 3.0123, 39.234, -1.490))
            expect_equal(average_fre(x, obs) %>% dplyr::pull(),
                         1.4)
          })


test_that("'average_fre()' calculates the same average
          frequency for the bodyweight data set is 3.906", {
  expect_equal(average_fre(bodyweight, obs) %>% dplyr::pull(),
                            3.906)
})
josh-mc/fabricated documentation built on April 25, 2022, 1:31 p.m.