Closed m7pr closed 9 months ago
> data <- teal_data() |> eval_code(
+ code = '
+ expr <- quote(x <- x + 1)
+ x <- 0
+ eval(expr) # @linksto x
+ '
+ )
> get_code(data, datanames = "x") %>% cat
expr <- quote(x <- x + 1)
x <- 0
eval(expr)
That's better, thank you.
Is it possible to have eval(expr)
be included automatically, like with assign
and data
?
@chlebowa I'm not sure. We do extract library()
automatically. For data()
and assign()
we only extended the detection so that it understands data()
and assign()
as ways of the assignment and they extract those lines if they refer to the object for which you are trying to get the code. For eval({})
if the object is inside {}
then this is also tackled. But I would not automatically extract eval
always, cause it sometimes can refer to different object than the one you are asking the code for.
Oh, I don't mean always.
> data <- teal_data() |> eval_code(
+ code = '
+ expr <- quote(x <- x + 1)
+ x <- 0
+ eval(expr)
+ '
+ )
> get_code(data, datanames = "x") %>% cat
expr <- quote(x <- x + 1)
x <- 0
We know to return the line that creates expr
but we don't know to return the line where it is evaluated.
I think at some point this could be possible but I would like to avoid trying this out before the very close release. We can try and start an issue to think about it. And currently let's merge this one that fixes an issue where #@linksto x
tag is in the last line which also contains eval
Created an issue for that in here https://github.com/insightsengineering/teal.data/issues/270
Close #267
Used @gogonzo solution from this PR to fix this https://github.com/insightsengineering/teal.data/pull/262/files#diff-66a61facc4f5ca86215d63af40e2645b364950439051784916316ef78d5073c8R102-R110