tests/testthat/test-lab_matrix.R

context("lag_matrix.R")

test_that("checking",{
  x <- matrix( 1:16, nrow=4, ncol=4)
  x <- x + t(x)
  diag(x) <- 0
  x  
  
  expect_that(lag_matrix(), throws_error())
  expect_that(lag_matrix(x), throws_error())
  expect_that( lag_matrix(x,1), throws_error())
  
  y <- lag_matrix(x, 0, 1 )
  expect_that(sum(y), equals(0) )
  y <- lag_matrix(x,0,10)
  expect_that( sum(y), equals(4) )
  
}
)
dyerlab/gstudio documentation built on Feb. 2, 2024, 8:24 p.m.