Sealing the R Objects Test and Assert Conditions

Record the state of R object. Outputs include object class and attributes. This helps reduce errors in test results by manual description. The goal is to improve the efficiency of data analysis and package development.

CRAN_Status_Badge CRAN RStudio mirror downloads minimal R version Depsy

Travis build status Coverage status

lifecycle npm


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.


sealr is available on CRAN.


For developers, install from GitHub.


How to use

  1. (As usual) Create an R object.
  2. Execute the function of sealr (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.
x <- seq(1, 9, by = 2)
design_class(x, seal = TRUE)
#> #' ℹ: Labeling on 2018-04-13 by the sealr package (v0.1.0.9000)
#> expect_is(
#>   x,
#>   "numeric"
#> )
design_range(x, seal = TRUE)
#> Warning: clipr not available. check clipr configuration.
#> #' ℹ: Labeling on 2018-04-13 by the sealr package (v0.1.0.9000)
#> expect_equal(
#>   range(x, na.rm = TRUE),
#>   c(1, 9)
#> )

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)

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.

#> #' ℹ: Labeling on 2018-04-13 by the sealr package (v0.1.0.9000)
#> test_that("check iris statement", {
#>   expect_is(
#>     iris,
#>     "data.frame"
#>   )
#>   expect_equal(
#>     dim(iris),
#>     c(150L, 5L)
#>   )
#>   expect_named(
#>     iris,
#>     c(
#>       "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width",
#>       "Species"
#>     )
#>   )
#>   expect_equal(
#>     iris %>% purrr::map(class) %>% unname(),
#>     list("numeric", "numeric", "numeric", "numeric", "factor")
#>   )
#> })
my_data <- list(A = letters, B = trees)
transcribe(my_data, load_testthat = FALSE, ts = FALSE)
#> test_that("check my_data statement", {
#>   expect_is(
#>     my_data,
#>     "list"
#>   )
#>   expect_length(
#>     my_data,
#>     2L
#>   )
#>   expect_named(
#>     my_data,
#>     c("A", "B")
#>   )
#> })

To get started, please read our introduce vignette.

Related projects on the test and assertion

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct.

By participating in this project you agree to abide by its terms.


sealr 0.1.1 (2018-06-30)

  • Folloing glue update.
  • Fixed CRAN test warning.

sealr 0.1.0 (2018-03-31)

  • Version 0.1.0 is on CRAN.
  • Implement the basic function.
    • design_*(): Print an R object test result.
    • transcribe(): Transcribe R object assert conditions. Currently it corresponds to 8 classes. (#3)


  • Added a file to track changes to the package.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.1 by Shinya Uryu, 5 months ago

Report a bug at

Browse source code at

Authors: Shinya Uryu [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports clipr, clisymbols, digest, dplyr, glue, magrittr, purrr, rlang, rstudioapi, styler, tibble, tidyr

Suggests covr, testthat, knitr, rmarkdown, withr

See at CRAN