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

Unclear how pander::eval captures stdout. #372

Open
andystopia opened this issue Sep 7, 2024 · 2 comments
Open

Unclear how pander::eval captures stdout. #372

andystopia opened this issue Sep 7, 2024 · 2 comments

Comments

@andystopia
Copy link

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

@daroczig
Copy link
Member

daroczig commented Sep 8, 2024

evals tries to do so many things that I'm embarrassed now looking at it after so many years since implementing it 😊 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"

@andystopia
Copy link
Author

andystopia commented Sep 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants