knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Data is not always what you think. Someone may change a single value or the data type may be different depending on the specification the API. We need to be aware of these data changes as soon as possible (It is hard to review from the final result!).
You can use tests and asserts to check data behavior. Although the testthat package is originally used for unit test of R package, this framework is wide and applicable to any R object. On the other hand, it is time-consuming task to enter the state of existing objects, and there is a possibility of mistakes as well.
The goal of sealr is to reduce the burden of writing unit tests and assertion that record the state of objects. Applying a function of sealr to the target object outputs the test code that record the current state.
design_*()
or transcribe()
) against a object whose state is to be record.design_*()
... The preamble is fixed and consists of the function name bearing test items (eg. design_class()
, design_length()
, etc.).transcribe()
... Sets of design_*()
.It is a generic function and returns combinations according to the class of the object.library(sealr) library(testthat)
x <- seq(1, 9, by = 2) design_class(x, seal = TRUE) design_range(x, seal = TRUE)
You can copy the output, but if you activate the clip argument, the output result will be in a copied state, pasting that value is too easy. This feature depends on the clipr package.
design_class(x, seal = TRUE, clip = TRUE) expect_is( x, "numeric" )
transcribe()
is a generic function that produces output according to the class of the object. Currently it suports to 8 classes, but we plan to add various classes in future upgrades.
transcribe(iris) my_data <- list(A = letters, B = trees) transcribe(my_data, load_testthat = FALSE, ts = FALSE)
Both design_*()
and transcribe()
have the following common arguments (Ref. ?seal
).
library(testthat)
when TRUEdesign_class()
design_length()
Suports to 8 classes. Default test of the class.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.