Is it possible to interactively launch code chunks inside a slide in revealjs?? #12705
Unanswered
jessijessi
asked this question in
Q&A
Replies: 1 comment 5 replies
-
It depends where you want the code to be executed. See Python/R (WASM): There are also: From a discussion with @EmilHvitfeldt you can use JavaScript and WASM compiled language, for example with R: ---
title: "Untitled"
format:
revealjs:
include-before-body:
- text: |
<script>
import('https://webr.r-wasm.org/latest/webr.mjs').then(
async ({ WebR }) => {
const webR = new WebR();
await webR.init();
window.runWebR = async (expr) => {
let result = await webR.evalR(expr);
let output = result.toArray();
console.log('Result of running `rnorm` from webR: ', output);
};
}
);
</script>
---
## Slide 1
```{=html}
<button onclick="runWebR('rnorm(10,5,1)')">Click Me</button>
``` Note that the output is sent to the console. You need to implement your own logic from there. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Hi everyone,
I'm wondering if it's possible to add, in a Quarto documentin revealjs format, a code chunk which can be executed by clicking a button directly on the slide. If it is, what option do I need to set? I've been searching for a while but haven't found any information.
Thanks in advance,
Best regards
Jessica
Beta Was this translation helpful? Give feedback.
All reactions