r-wasm / quarto-drop

Drop down an interactive R or Python console, code editor, and plotting window from the top of your Quarto slides.
https://r-wasm.github.io/quarto-drop/
MIT License
158 stars 4 forks source link

Loading packages not working #12

Open jtr13 opened 2 months ago

jtr13 commented 2 months ago

First of all, thanks for a great extension!

This example isn't working for me:

format:
  revealjs:
    drop:
      engine: webr
      webr:
        packages:
          - ggplot2
          - dplyr

When I try to make a plot with ggplot2 I get: Error in ggplot(mtcars, aes(wt, mpg)) : could not find function "ggplot"

georgestagg commented 1 month ago

Hi, thanks for the kind words!

Does it work if you explicitly load the library with library(ggplot2) before calling the ggplot() command? It may be that the package is installed but not loaded automatically.

jtr13 commented 1 month ago

Yes, that works. Perhaps I misunderstood that by including the packages in the YAML I wouldn't need to do that.

georgestagg commented 1 month ago

Sometimes it is useful to have a package that is installed, but not loaded with library(), which is why that is the default behaviour.

We can add an additional yaml configuration option to also load the package once it has finished installing.

jtr13 commented 1 month ago

That would be a welcome addition.