tests/testthat/test-prepare_data.R

test_that("prepare_data filters and processes data correctly", {
  # Ensure the required packages are loaded for the test
  library(lubridate)

  # Example input data
  data <- data.frame(
    Date = c("19990101", "19990115", "19990201", "19990301", "19990315", "19990401"),
    Var1 = c(1, 2, -99.99, 4, 5, -99.99),
    Var2 = c(3, -99.99, 6, 7, 8, 9),
    Var3 = c(10, 11, 12, 13, -99.99, 15)
  )

  # Run the function with default date range
  result <- prepare_data(data, date_column_index = 1, start_date = '19990101', end_date = '19990430')

  # Check the structure of the result
  expect_type(result, "list")
  expect_true("x" %in% names(result))
  expect_true("mon" %in% names(result))
  expect_true("count" %in% names(result))
  expect_true("Date" %in% names(result))
})

Try the REN package in your browser

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

REN documentation built on Oct. 10, 2024, 5:06 p.m.