Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objects with reference semantics can break containment of qenv #252

Open
chlebowa opened this issue Jan 16, 2024 · 0 comments
Open

objects with reference semantics can break containment of qenv #252

chlebowa opened this issue Jan 16, 2024 · 0 comments
Labels

Comments

@chlebowa
Copy link
Contributor

Objects that have reference semantics (e.g. environments, R6 objects, data.table), when created in the global environment and packaged into teal_data, allow for modifying the contents of teal_data from without.

library(teal.data)
library(data.table)

d1 <- as.data.table(iris)
td <- teal_data(d1 = d1, code = quote(d1 <- as.data.table(iris)))
within(td, print(head(d1)))
get_code(td) |> cat()

d1[, species := as.integer(Species)]
within(td, print(head(d1)))

This is a potential breach in code reproducibility.


Note that once code is evaluated within teal_data, the result is a deep copy because @env is cloned under the hood.

tdd <- within(td, d1 <- head(d1))
within(tdd, print(d1))
within(td, print(d1))
@chlebowa chlebowa added the core label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant