knitr::opts_chunk$set( error = TRUE, collapse = TRUE, comment = "#>", out.width = "100%" )
library(testthat) library(jeksterslabRmatrix) context("Test is.square.")
matrix.T <- matrix( data = 1:9, nrow = 3 ) matrix.F <- matrix( data = 1:10, 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.F, row.names = TRUE, caption = "Non-Square Matrix" ) knitr::kable( x = matrix.T, row.names = TRUE, caption = "Square Matrix" )
knitr::kable( x = data.frame( Item = c( "Non-Square Matrix", "Square Matrix" ), Parameter = c( "FALSE", "TRUE" ), Results = c( is.square(matrix.F), is.square(matrix.T) ) ), row.names = FALSE )
test_that("is.square is TRUE", { expect_true( is.square(matrix.T) ) })
test_that("is.square is FALSE", { expect_false( is.square(matrix.F) ) })
test_that("is.square is FALSE (expect_error)", { expect_error( is.square(matrix.F, stop = TRUE) ) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.