tests/testthat/test-preprocess_bout.R

testthat::test_that("preprocess_bout gives same as preprocess_bout_r", {
  skip_if_no_forest()
  csv_file = system.file("test_data_bout.csv", package = "walking")
  testthat::skip_if_not_installed("readr")
  data = readr::read_csv(csv_file)
  colnames(data)[colnames(data) == "UTC time"] = "time"
  bout = preprocess_bout(data, sample_rate = 10)
  bout_r = preprocess_bout_r(data, sample_rate = 10)
  testthat::expect_named(bout, c("vm_bout", "vm_data"))
  testthat::expect_s3_class(bout$vm_data, "data.frame")
  testthat::expect_named(bout$vm_data, c("time", "vm"))
  testthat::expect_identical(length(bout$vm_bout), 2L)
  testthat::expect_equal(bout$vm_data$time, bout_r$vm_data$time)
  testthat::expect_true(
    all(abs(bout$vm_data$vm - bout_r$vm_data$vm) <= 1e-4)
  )
})

Try the walking package in your browser

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

walking documentation built on Aug. 4, 2026, 1:07 a.m.