r-wasm / quarto-live

WebAssembly powered code blocks and exercises for both the R and Python languages in Quarto documents
https://r-wasm.github.io/quarto-live/
MIT License
134 stars 10 forks source link

Execute only the selected parts of the code block #48

Open tmieno2 opened 3 months ago

tmieno2 commented 3 months ago

It would be great to be able to run only the selected parts of the code.

This can be useful for a number of reasons. For example, you may look at mtcars to see what other variables it has without deleting all the other codes. You may want to run only plot(fit) without displaying summary(fit) without removing summary(fit) from the console.

fit = lm(mpg ~ am, data = mtcars)
summary(fit)
plot(fit)

This is possible in quarto-webr, and I found myself (and students) using this feature a lot when I teach.

georgestagg commented 3 months ago

Sounds good! If you or others have ideas on the best workflow and/or shortcuts for students and readers, please feel free to chip in here.

@coatless's extension handles this well, and I think we can copy the approach here in the first pass. IIUC the rules would be: