tests/testthat/test-economics_df_ts.R

# timeseriesdatasets package, a collection of time series data sets for R.
# Copyright (C) 2024  Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# data set economics_df_ts

# library(timeSeriesDataSets) activate package timeSeriesDataSets

library(testthat)


test_that("economics_df_ts has the correct class of object", {
  expect_true("spec_tbl_df" %in% class(economics_df_ts))  # Check if 'spec_tbl_df' is among the classes
  expect_true("tbl_df" %in% class(economics_df_ts)) # Check if 'tbl_df' is among the classes
  expect_true("tbl" %in% class(economics_df_ts)) # Check if 'tbl' is among the classes
  expect_true("data.frame" %in% class(economics_df_ts)) # Check if 'data.frame' is among the classes

})


# Test that 'economics_df_ts' has the correct number of observations

test_that("economics_df_ts has the correct number of observations", {
  expect_equal(length(economics_df_ts), 6)
})




test_that("economics_df_ts has the correct frequency", {
  # Check if the frequency of 'economics_df_ts' is 1 (annual data)
  expect_equal(frequency(economics_df_ts), 1)
})






test_that("economics_df_ts does not contain missing values", {
  # Check for NA values in the dataset
  expect_false(any(is.na(economics_df_ts)))
})

Try the timeSeriesDataSets package in your browser

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

timeSeriesDataSets documentation built on Sept. 14, 2024, 1:07 a.m.