From 5dfce112c796d3ceac06ec6e630067a1107f7206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:57:55 +0100 Subject: [PATCH] fix: add data import code cell and link to CSV file (cherry picked from commit eb203c95c1b998ba7ff0bafb2edd05af49f981c2) --- docs/computations/ojs.qmd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/computations/ojs.qmd b/docs/computations/ojs.qmd index ea1fb39c1d..3c661f94b7 100644 --- a/docs/computations/ojs.qmd +++ b/docs/computations/ojs.qmd @@ -17,6 +17,10 @@ OJS works in any Quarto document (plain markdown as well as Jupyter and Knitr do We'll start with a simple example based on Allison Horst's [Palmer Penguins](https://allisonhorst.github.io/palmerpenguins/) dataset. Here we look at how penguin body mass varies across both sex and species (use the provided inputs to filter the dataset by bill length and island): +```{ojs} +data = FileAttachment("palmer-penguins.csv").csv({ typed: true }) +``` + ```{ojs} filtered = data.filter(function(penguin) { return bill_length_min < penguin.bill_length_mm && @@ -57,9 +61,9 @@ Plot.rectY(filtered, ) ``` -Let's take a look at the source code for this example. First we create an `{ojs}` cell that reads in some data from a CSV file using a [FileAttachment](https://observablehq.com/@observablehq/file-attachments): +Let's take a look at the source code for this example. First we create an `{ojs}` cell that reads in some data from a CSV file (*e.g.*, [`palmer-penguins.csv`](palmer-penguins.csv){target="_blank" download="palmer-penguins.csv"}) using a [FileAttachment](https://observablehq.com/@observablehq/file-attachments): -```{ojs} +```{{ojs}} data = FileAttachment("palmer-penguins.csv").csv({ typed: true }) ```