insightsengineering / insightsengineering/teal.data

[Feature Request]: Data verification doesn't evaluate code in all cases

Open
#375 0 comments 0 reactions 0 assignees View on GitHub
bug core enhancement
Dominant language
R
Stars
11
Forks
9
PR merge metrics
No merged PRs in 30d

Description

### Feature description

Data validation doesn't execute code that is present on the object, failing to verify an object that is reproducible. If the data object is provided on the `...` argument is also not found:

``` r
library("teal.data")
#> Loading required package: teal.code
packageVersion("teal.data")
#> [1] '0.7.0.9004'
packageVersion("teal.code")
#> [1] '0.6.1.9004'
data_empty <- teal_data()
data_populated <- teal_data(code = "D5 <- diag(5)")
data_populated # No object as documented
#> ✖ code unverified
#> 🔒
#> Parent:
verify(data_populated) # Verification fails even if code is present
#> Error: Code verification failed.
#> Object(s) created with code that do not exist in data_populated:
#> • D5

# Code is executed but data not found
tdata2 <- teal_data(x1 = iris, code = "x2 <- x1")
tdata2
#> ✖ code unverified
#> 🔒
#> Parent:
#> Bindings:
#> - x1: [data.frame]
verify(tdata2)
#> Error: object 'x1' not found
#> when evaluating qenv code:
#> x2 <- x1
```

Created on 2025-07-09 with [reprex v2.1.1](https://reprex.tidyverse.org)

I thought that objects supplied would be found by the verification process

---
Related to this, the only way to evaluate the code supplied on `teal_data()` is by `data_populated_evaluated <- eval_code(data_populated, code = get_code(data_populated))` . Maybe in case of `teal_data` object and missing code argument it could `get_code(object)` and evaluate that?

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.