Skip to content

Commit

Permalink
add short guide to adding data for WebR
Browse files Browse the repository at this point in the history
  • Loading branch information
widdowquinn committed May 17, 2024
1 parent 949f336 commit aa635c5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ This version of the template includes:

1. Make changes to the `.qmd` files, updating chapter information in `_quarto.yml` and `R` package information in `DESCRIPTION`, as needed for your material
2. Commit your changes locally to the git repository
3. Push your changes to the GitHub repository
3. Push your changes to the GitHub repository

### Using `WebR`

[`WebR`](https://github.com/coatless/quarto-webr) provides a sandboxed version of `R` that runs in the browser. This enables us to write workshops that ask students to use `R` "live" without requiring an installation on their machine, thereby increasing accessibility and avoiding some technical issues.

Being sandboxed, `WebR` has no interaction with the local filesystem, and there are limitations on the libraries that can be installed. There is no quick route around the library limitations, but we can provide example files for students to work with on their machines.

#### Providing data for `WebR` exercises

We need to make the datasets available in the workshop repository, and preload them on the exercise Quarto page in a `webr-r` cell with the `setup` context. An example can be seen at [https://github.com/sipbs-compbiol/BM214-Workshop-3/blob/main/exercise-03_reporter.qmd](https://github.com/sipbs-compbiol/BM214-Workshop-3/blob/main/exercise-03_reporter.qmd) where the `reporter_curves.csv` file is downloaded in the first `webr-r` cell.

There is also an example in the `webr-example.qmd` `WebR` playground page, in this repository template.
4 changes: 4 additions & 0 deletions sipbs-compbiol-book-template.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
14 changes: 14 additions & 0 deletions webr-example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ filters:
```{webr-r}
#| context: setup
# Download reporter data
download.file('https://raw.githubusercontent.com/sipbs-compbiol/BM214-Workshop-3/main/assets/data/reporter_curves.csv', 'reporter_curves.csv')
library(ggplot2)
library(palmerpenguins)
library(tidyverse)
Expand All @@ -36,6 +39,17 @@ This `WebR` instance has three packages installed:

Open the callout boxes below to see some examples you can try in the code cell above.

::: { .callout-tip collapse="true }
## Play with data from a GitHub repository

One of our [BM214 workshops](https://sipbs-compbiol.github.io/BM214-Workshop-3/) involves a `WebR`-supported interactive exercise involving simulated reporter curves. We preload this data in the `setup` cell (see source code), and you can interact with it below with the code:

```r
data <- read.csv("reporter_curves.csv")
glimpse(data)
```
:::

::: { .callout-tip collapse="true" }
## Investigate Palmer's Penguins

Expand Down

0 comments on commit aa635c5

Please sign in to comment.