pander icon indicating copy to clipboard operation
pander copied to clipboard

Unclear how pander::eval captures stdout.

Open andystopia opened this issue 1 year ago • 2 comments

When executing in the R REPL, I find a surprising (to me) result.

> pander::evals("print(1:4)")$stdout
NULL

I would expect this print statement to print to stdout and the results would be visible in the stdout field, but this is not the case.

  1. Is this the intended behavior?
  2. Is there a way to get the printed object?

For context, I'm trying to build a literate programming environment within the Typst typesetter.

Thanks to the maintainers for all your hard work, this seems like such a hard problem throughout all my research on it

andystopia avatar Sep 07 '24 18:09 andystopia

evals tries to do so many things that I'm embarrassed now looking at it after so many years since implementing it :blush: I would need some time to go through the details to check on the above, but after a quick check, I think you might be happier with pander::eval.msgs, no?

> eval.msgs("print(1:3)")
$src
[1] "print(1:3)"

$result
NULL

$output
NULL

$type
[1] "integer"

$msg
$msg$messages
NULL

$msg$warnings
NULL

$msg$errors
NULL


$stdout
[1] "[1] 1 2 3"

daroczig avatar Sep 08 '24 12:09 daroczig

Yess, I just tried it! That's so helpful!! Thank you so much :D

andystopia avatar Sep 08 '24 15:09 andystopia