-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
96,598 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{:modes {:html {:toc true} | ||
:quarto-book {:quarto {:format {:html {:toc true}} | ||
:code-block-background true | ||
:embed-resources false}} | ||
:quarto-standalone {:quarto {:format {:html {:toc true}} | ||
:code-block-background true | ||
:embed-resources true}} | ||
:quarto-reveal {:quarto {:format {:revealjs {:theme :serif | ||
:navigation-mode :vertical | ||
:transition :slide | ||
:background-transition :fade | ||
:incremental true | ||
:embed-resources false}}}}} | ||
:default-mode {}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.quarto/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# A chapter with R code | ||
|
||
## Section 1 | ||
|
||
```{r} | ||
1+2 | ||
``` | ||
|
||
## Section 2 | ||
|
||
```{r} | ||
hist(rnorm(99)) | ||
``` | ||
|
||
## Section 3 | ||
|
||
Trying `rmarkdown-clojure`: | ||
|
||
```{r setup, include=FALSE} | ||
find_nrepl_port_up <- function() { | ||
wd <- getwd() | ||
while(wd != dirname(wd)) { | ||
f <- paste0(wd,"/.nrepl-port") | ||
if(file.exists(f)) return(paste0("@",f)) | ||
wd <- dirname(wd) | ||
f <- NULL | ||
} | ||
} | ||
port_file <- find_nrepl_port_up() | ||
if(is.null(port_file)) stop("nREPL port not found") | ||
library(knitr) | ||
knitr_one_string <- knitr:::one_string | ||
nrepl_cmd <- "rep" | ||
opts_chunk$set(comment=NA, highlight=TRUE) | ||
knit_engines$set(clojure = function(options) { | ||
rep_params <- if((options$results == "asis") || isTRUE(options$stdout_only)) { | ||
"--print 'out,1,%{out}' --print 'value,1,' -p" | ||
} else { | ||
"-p" | ||
} | ||
code <- paste(rep_params, port_file, shQuote(knitr_one_string(options$code))) | ||
out <- if (options$eval) { | ||
if (options$message) message('running: ', nrepl_cmd, ' ', code) | ||
tryCatch( | ||
system2(nrepl_cmd, code, stdout = TRUE, stderr = TRUE, env = options$engine.env), | ||
error = function(e) { | ||
if (!options$error) stop(e) | ||
paste('Error in running command', nrepl_cmd) | ||
} | ||
) | ||
} else '' | ||
if (!options$error && !is.null(attr(out, 'status'))) stop(knitr_one_string(out)) | ||
engine_output(options, options$code, out)}) | ||
``` | ||
|
||
|
||
```{clojure} | ||
(+ 1 2) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import url(https://cdn.jsdelivr.net/npm/[email protected]/distr/fira_code.css); | ||
|
||
/*-- scss:rules --*/ | ||
.table {width:auto} | ||
|
||
code {font-family: 'Fira Code Medium', monospace;} | ||
|
||
.clay-image img {max-width: 50px} | ||
|
||
|
||
body {background-color: lightgray} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
x,y | ||
0,0.3836032408847967 | ||
1,0.36099346062945714 | ||
2,0.6240868963153352 | ||
3,0.7246690729960028 | ||
4,0.5975090540638364 | ||
5,0.20452572769776822 | ||
6,0.5511639152916283 | ||
7,0.27974509484024457 | ||
8,0.6596151426796825 | ||
9,0.5152187538509085 | ||
10,0.26186856306323003 | ||
11,0.6324781560712595 | ||
12,0.5047721363185802 | ||
13,0.7703025232984473 | ||
14,0.822270041838778 | ||
15,0.3901692171454785 | ||
16,0.7630880752260801 | ||
17,0.34503815301731067 | ||
18,0.4479862660558652 | ||
19,0.8383710495075298 | ||
20,0.34598244326928596 | ||
21,0.03443837445931264 | ||
22,0.0766543855475148 | ||
23,0.26215444914218144 | ||
24,0.8081202564318113 | ||
25,0.2948146779050138 | ||
26,0.2785521517634043 | ||
27,0.4397310391724576 | ||
28,0.03969967937001806 | ||
29,0.8780331941928368 | ||
30,0.7361137933803834 | ||
31,0.23961551606404985 | ||
32,0.8914189905860413 | ||
33,0.05577558011330963 | ||
34,0.08656012228954679 | ||
35,0.9175494053476839 | ||
36,0.6635495844628126 | ||
37,0.686764901986259 | ||
38,0.2665897059105773 | ||
39,0.4056969843274695 | ||
40,8.937977700980149E-4 | ||
41,0.9668311030370961 | ||
42,0.6240538222794699 | ||
43,0.6141638189461234 | ||
44,0.6270076229282414 | ||
45,0.8198539930933 | ||
46,0.9687652425920751 | ||
47,0.5236768166299018 | ||
48,0.5239199825984001 | ||
49,0.5370364960428063 | ||
50,0.4230666667297742 | ||
51,0.6383038579962004 | ||
52,0.6176816089093122 | ||
53,0.4526243598162958 | ||
54,0.402512104296995 | ||
55,0.18838047583908013 | ||
56,0.7654289326274079 | ||
57,0.15610308936343276 | ||
58,0.3079899513752148 | ||
59,0.32634982064393825 | ||
60,0.8562486433878495 | ||
61,0.9840664041252284 | ||
62,0.5428441487708802 | ||
63,0.4420111373883603 | ||
64,0.1359812914841806 | ||
65,0.3093651340234388 | ||
66,0.282025627494093 | ||
67,0.6387113573757942 | ||
68,0.4452034264489978 | ||
69,0.4508090211272199 | ||
70,0.015033246684376667 | ||
71,0.3583030637349893 | ||
72,0.9199791703925813 | ||
73,0.863608399573907 | ||
74,0.26037965614722003 | ||
75,0.12023176343700503 | ||
76,0.8465738197018933 | ||
77,0.6389064107765796 | ||
78,0.006544266481435468 | ||
79,0.3489036186402509 | ||
80,0.7841740125352934 | ||
81,0.24016680926561917 | ||
82,0.3728523374278119 | ||
83,0.3035246106105287 | ||
84,0.7737597312649241 | ||
85,0.8348461110744574 | ||
86,0.703444892560047 | ||
87,0.19589080346489507 | ||
88,0.43662587904891614 | ||
89,0.5416934109142241 | ||
90,0.8084819693214834 | ||
91,0.6841485071772843 | ||
92,0.03265199549574971 | ||
93,0.4071844858196745 | ||
94,0.3489470281280933 | ||
95,0.06433212851494186 | ||
96,0.09627079344204548 | ||
97,0.9490119258322847 | ||
98,0.42489789647757326 | ||
99,0.6465267769814818 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "42932a5f", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"3" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"1+2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d64bd191", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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} | ||
//| panel: input | ||
viewof bill_length_min = Inputs.range( | ||
[32, 50], | ||
{value: 35, step: 1, label: "Bill length (min):"} | ||
) | ||
viewof islands = Inputs.checkbox( | ||
["Torgersen", "Biscoe", "Dream"], | ||
{ value: ["Torgersen", "Biscoe"], | ||
label: "Islands:" | ||
} | ||
) | ||
``` | ||
|
||
::: {.panel-tabset} | ||
|
||
## Plot | ||
|
||
```{ojs} | ||
Plot.rectY(filtered, | ||
Plot.binX( | ||
{y: "count"}, | ||
{x: "body_mass_g", fill: "species", thresholds: 20} | ||
)) | ||
.plot({ | ||
facet: { | ||
data: filtered, | ||
x: "sex", | ||
y: "species", | ||
marginRight: 80 | ||
}, | ||
marks: [ | ||
Plot.frame(), | ||
] | ||
} | ||
) | ||
``` | ||
|
||
## Data | ||
|
||
```{ojs} | ||
Inputs.table(filtered) | ||
``` | ||
|
||
::: | ||
|
||
```{ojs} | ||
data = FileAttachment("palmer-penguins.csv").csv({ typed: true }) | ||
``` | ||
|
||
```{ojs} | ||
filtered = data.filter(function(penguin) { | ||
return bill_length_min < penguin.bill_length_mm && | ||
islands.includes(penguin.island); | ||
}) | ||
``` |
Oops, something went wrong.