You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set webR options from within Quarto Document YAML (#13)
* Add old code cell type to check against
* Add more documentation to the README file
* Bump embedded workers to the 0.1.1 version
* Re-write the initialization portion of WebR to allow for user-specified variables in the quarto document's meta field
* Update the template file with new YAML options
* Bump the extension
* Fix code cell specification
* Better description
* Remove log diagnostics
Add to the document header YAML the `packages` key under `webr` with each package listed using an array, e.g.
79
+
80
+
```yaml
81
+
---
82
+
webr:
83
+
packages: ['ggplot2', 'dplyr']
84
+
---
71
85
```
72
86
73
-
You can view what packages are available by either executing the following R code (either with WebR or just R):
87
+
#### Install on an as needed basis
88
+
89
+
Packages may also be installed inside of a code cell through the built-in [`webr::install()` function](https://docs.r-wasm.org/webr/latest/packages.html#example-installing-the-matrix-package). For example, to install `ggplot2`, you would need to use:
The `quarto-webr` extension supports specifying the following `WebROptions` options:
98
+
99
+
- `home-dir`: The WebAssembly user’s home directory and initial working directory ([`Documentation`](https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html#homedir)). Default: `'/home/web_user'`.
100
+
- `base-url`: The base URL used for downloading R WebAssembly binaries. ([`Documentation`](https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html#baseurl)). Default: `'https://webr.r-wasm.org/[version]/'`.
101
+
- `service-worker-url`: The base URL from where to load JavaScript worker scripts when loading webR with the ServiceWorker communication channel mode ([`Documentation`](https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html#serviceworkerurl)). Default: `''`.
102
+
103
+
The extension also has native options for:
104
+
105
+
- `show-startup-message`: Display in the document header the state of WebR initialization. Default: `true`
106
+
- `show-header-message`: Display in the document header whether COOP and COEP headers are in use for faster page loads. Default: `false`
107
+
108
+
For these options to be active, they must be placed underneath the `webr` entry in the documentation header, e.g.
109
+
110
+
```markdown
111
+
---
112
+
title: WebR in Quarto HTML Documents
113
+
format: html
114
+
engine: knitr
115
+
webr:
116
+
show-startup-message: false
117
+
show-header-message: false
118
+
home-dir: '/home/r-user/'
119
+
packages: ['ggplot2', 'dplyr']
120
+
filters:
121
+
- webr
122
+
---
123
+
```
82
124
83
125
## Known Hiccups
84
126
@@ -96,6 +138,8 @@ If `webr-worker.js` or `webr-serviceworker.js` are not found when the document l
96
138
└── webr-worker.js
97
139
```
98
140
141
+
Still having trouble? Try specifying where the worker files are located using the `service-worker-url` option in the document's YAML header.
142
+
99
143
### Directly accessing rendered HTML
100
144
101
145
When using `quarto preview` or `quarto render`, the rendered HTML document is being shown by mimicking a server running under `https://localhost/`. Usually, everything works in this context assuming the above directory structure is followed. However, if you **directly** open the rendered HTML document, e.g. `demo-quarto-web.html`, inside of a Web Browser, then the required WebR components cannot be loaded for security reasons. You can read a bit more about the problem in this [StackOverflow answer](https://stackoverflow.com/questions/6811398/html5-web-workers-work-in-firefox-4-but-not-in-chrome-12-0-742-122/6823683#6823683).
0 commit comments