Skip to content

Commit 95ad158

Browse files
cgraham-rsjonkeanetoph-allen
authored
Add quarto-script-r (#110)
* Add quarto-script-r * Add exception to .gitignore for manifest.json * Apparently I lost the manifest due to the .gitignore problem * Update extensions/quarto-script-r/manifest.json Co-authored-by: Toph Allen <[email protected]> --------- Co-authored-by: Jonathan Keane <[email protected]> Co-authored-by: Toph Allen <[email protected]>
1 parent 472ec7a commit 95ad158

File tree

8 files changed

+988
-0
lines changed

8 files changed

+988
-0
lines changed

.github/workflows/extensions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
plumbertableau-example: extensions/plumbertableau-example/**
4545
fastapitableau-example: extensions/fastapitableau-example/**
4646
portfolio-report: extensions/portfolio-report/**
47+
quarto-script-r: extensions/quarto-script-r/**
4748
usage-metrics-dashboard: extensions/usage-metrics-dashboard/**
4849
4950
# Runs for each extension that has changed from `simple-extension-changes`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.quarto/
2+
*.csv
3+
*.json
4+
script.html
5+
script_files
6+
/email-preview/
7+
.output_metadata.json
8+
9+
# Always include manifest.json
10+
!manifest.json
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
README.md
2+
thumbnail.jpg
3+
script.html
4+
script_files
5+
.output_metadata.json
6+
email-preview
7+
adelie-m.csv
8+
adelie-m.json
9+
gentoo-f.csv
10+
gentoo-f.json
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Run an R Script using Quarto
2+
3+
## About this example
4+
5+
This data transformation script uses Quarto and R. It is an example of how you might automate regular imports and transformations from a data source. JSON and CSV files are exported and made available for download.
6+
7+
The script also generates a custom email, with the generated CSV files as attachments.
8+
9+
10+
## Learn more
11+
12+
* [Quarto](https://quarto.org)
13+
* [Quarto: Rendering Script Files](https://quarto.org/docs/computations/render-scripts.html)
14+
15+
## Requirements
16+
17+
* Quarto version 1.4 or higher
18+
* R version 4.4 or higher
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project:
2+
title: "Penguin data transformations"

extensions/quarto-script-r/manifest.json

Lines changed: 885 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#' ---
2+
#' title: "Penguin data transformations"
3+
#' subtitle: "Exported as JSON and CSV"
4+
#' format: email
5+
#' email-attachments:
6+
#' - "adelie-m.csv"
7+
#' - "gentoo-f.csv"
8+
#' ---
9+
10+
#' ## Setup
11+
library(palmerpenguins)
12+
library(jsonlite)
13+
14+
#' ## Filtering
15+
gentoo_f <- subset(penguins, species == "Gentoo" & sex == "female")
16+
adelie_m <- subset(penguins, species == "Adelie" & sex == "male")
17+
18+
#' ## Statistics (Gentoo)
19+
summary(gentoo_f)
20+
21+
#' ## Statistics (Adelie)
22+
summary(adelie_m)
23+
24+
#' ## Export
25+
write(jsonlite::toJSON(gentoo_f), "gentoo-f.json")
26+
write.csv(gentoo_f, "gentoo-f.csv")
27+
write(jsonlite::toJSON(adelie_m), "adelie-m.json")
28+
write.csv(adelie_m, "adelie-m.csv")
29+
30+
#' # Exported data
31+
#'
32+
#' * [gentoo-f.json](gentoo-f.json)
33+
#' * [gentoo-f.csv](gentoo-f.csv)
34+
#' * [adelie-m.json](adelie-m.json)
35+
#' * [adelie-m.csv](adelie-m.csv)
36+
#'
37+
#' ::: {.email}
38+
#' ::: {.subject}
39+
#' Penguin data files
40+
#' :::
41+
42+
#| echo: false
43+
#| output: asis
44+
cat("Identified", nrow(gentoo_f), "female Gentoo penguins.\n")
45+
cat("Identified", nrow(adelie_m), "male Adelie penguins.\n")
46+
cat("\n")
47+
cat("CSV files are attached.\n")
48+
49+
#' :::

0 commit comments

Comments
 (0)