Learn R Programming

teal.data (version 0.5.0)

verify: Verify code reproducibility

Description

Checks whether code in teal_data object reproduces the stored objects.

Usage

verify(x)

Value

Input teal_data object or error.

Arguments

x

teal_data object

Details

If objects created by code in the @code slot of x are all_equal to the contents of the @env slot, the function updates the @verified slot to TRUE in the returned teal_data object. Once verified, the slot will always be set to TRUE. If the @code fails to recreate objects in teal_data@env, an error is raised.

Examples

Run this code
tdata1 <- teal_data()
tdata1 <- within(tdata1, {
  a <- 1
  b <- a^5
  c <- list(x = 2)
})
verify(tdata1)

tdata2 <- teal_data(x1 = iris, code = "x1 <- iris")
verify(tdata2)
verify(tdata2)@verified
tdata2@verified

tdata3 <- teal_data()
tdata3 <- within(tdata3, {
  stop("error")
})
try(verify(tdata3)) # fails


a <- 1
b <- a + 2
c <- list(x = 2)
d <- 5
tdata4 <- teal_data(
  a = a, b = b, c = c, d = d,
  code = "a <- 1
          b <- a
          c <- list(x = 2)
          e <- 1"
)
tdata4
try(verify(tdata4)) # fails

Run the code above in your browser using DataLab