knitr::opts_chunk$set( error = TRUE, collapse = TRUE, comment = "#>", out.width = "100%" )
library(testthat) library(jeksterslabRmatrix) context("Test is.invertible.")
matrix.T <- diag(2) matrix.F <- matrix( data = 1, nrow = 2, ncol = 2 ) colnames(matrix.T) <- paste0("col", 1:ncol(matrix.T)) rownames(matrix.T) <- paste0("row", 1:nrow(matrix.T)) colnames(matrix.F) <- paste0("col", 1:ncol(matrix.F)) rownames(matrix.F) <- paste0("row", 1:nrow(matrix.F)) knitr::kable( x = matrix.T, row.names = TRUE, caption = "Invertible Matrix" ) knitr::kable( x = matrix.F, row.names = TRUE, caption = "Non-Invertible Matrix" )
knitr::kable( x = data.frame( Item = c( "Invertible Matrix", "Non-Invertible Matrix" ), Parameter = c( "TRUE", "FALSE" ), Results = c( is.invertible(matrix.T), is.invertible(matrix.F) ) ), row.names = FALSE )
test_that("is.invertible is TRUE", { expect_true( is.invertible(matrix.T) ) })
test_that("is.invertible is FALSE", { expect_false( is.invertible(matrix.F) ) })
test_that("is.invertible is FALSE (expect_error)", { expect_error( is.invertible(matrix.F, stop = TRUE) ) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.