From 3720c981fdfd12e3fc1d4a61899c7bdc57205005 Mon Sep 17 00:00:00 2001 From: Chaz Date: Wed, 6 Mar 2024 12:11:10 -0700 Subject: [PATCH] update to use R and Py --- .github/workflows/publish.yml | 18 +- Projects/project1.qmd | 166 +------- Projects/project2.qmd | 169 +------- Projects/project3.qmd | 169 +------- Projects/project4.qmd | 170 +------- Projects/project5.qmd | 169 +------- Templates/DS250_Template.qmd | 195 +++++++++ Templates/DS350_Template.qmd | 28 ++ _site/cleansing.html | 383 +++++++++++++----- _site/competition.html | 342 ++++++++++++---- _site/search.json | 48 ++- .../bootstrap/bootstrap-dark.min.css | 12 +- _site/site_libs/bootstrap/bootstrap-icons.css | 148 +++++-- .../site_libs/bootstrap/bootstrap-icons.woff | Bin 164168 -> 176200 bytes _site/site_libs/bootstrap/bootstrap.min.css | 12 +- _site/site_libs/bootstrap/bootstrap.min.js | 6 +- _site/site_libs/quarto-html/anchor.min.js | 6 +- _site/site_libs/quarto-html/popper.min.js | 4 +- _site/site_libs/quarto-html/quarto.js | 29 +- _site/site_libs/quarto-nav/quarto-nav.js | 22 +- .../quarto-search/autocomplete.umd.js | 4 +- .../site_libs/quarto-search/quarto-search.js | 226 +++++++++-- _site/sitemap.xml | 59 --- cleansing.qmd | 29 ++ competition.qmd | 30 ++ 25 files changed, 1233 insertions(+), 1211 deletions(-) create mode 100644 Templates/DS250_Template.qmd create mode 100644 Templates/DS350_Template.qmd delete mode 100644 _site/sitemap.xml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 55f882f..78b95a3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,7 +19,8 @@ jobs: with: # To install LaTeX to build PDF book tinytex: true - + + # Comment out the below section if you are not using python - name: Install Python and Dependencies uses: actions/setup-python@v4 with: @@ -28,6 +29,21 @@ jobs: - run: pip install jupyter numpy pandas scikit-learn plotly.express #- run: pip install -r requirements.txt + # Comment out the 2 below section if you are not using R + - name: Install R + uses: r-lib/actions/setup-r@v2 + with: + r-version: '4.3.2' + use-public-rspm: true + + - name: Install R Dependencies + uses: r-lib/actions/setup-renv@v2 + with: + packages: + any::tidyverse + any::knitr + any::DT + - name: Render and Publish uses: quarto-dev/quarto-actions/publish@v2 with: diff --git a/Projects/project1.qmd b/Projects/project1.qmd index 5efe468..f2154af 100644 --- a/Projects/project1.qmd +++ b/Projects/project1.qmd @@ -25,168 +25,4 @@ execute: --- -```{python} -#| label: libraries -#| include: false -import pandas as pd -import numpy as np -import plotly.express as px -``` - - -## Elevator pitch - -_paste your elevator pitch here_ -_A SHORT (4-5 SENTENCES) PARAGRAPH THAT `DESCRIBES KEY INSIGHTS` TAKEN FROM METRICS IN THE PROJECT RESULTS THINK TOP OR MOST IMPORTANT RESULTS._ - -```{python} -#| label: project data -#| code-summary: Read and format project data -# Include and execute your code here -df = pd.read_csv("https://github.com/byuidatascience/data4names/raw/master/data-raw/names_year/names_year.csv") -``` - -__Highlight the Questions and Tasks__ - -## QUESTION|TASK 1 - -__COPY PASTE QUESTION|TASK 1 FROM THE PROJECT HERE__ - -_type your results and analysis here_ - -```{python} -#| label: Q1 -#| code-summary: Read and format data -# Include and execute your code here - - -``` - -_include figures in chunks and discuss your findings in the figure._ - -```{python} -#| label: Q1 chart -#| code-summary: plot example -#| fig-cap: "My useless chart" -#| fig-align: center -# Include and execute your code here -chart = px.bar(df.head(200), - x="name", - y="AK" -) -chart.show() -``` - - -```{python} -#| label: Q1 table -#| code-summary: table example -#| tbl-cap: "Not much of a table" -#| tbl-cap-location: top -# Include and execute your code here -mydat = df.head(1000)\ - .groupby('year')\ - .sum()\ - .reset_index()\ - .tail(10)\ - .filter(["year", "AK","AR"]) - -display(mydat) - -``` - - -## QUESTION|TASK 2 - -__COPY PASTE QUESTION|TASK 2 FROM THE PROJECT HERE__ - -_type your results and analysis here_ - -```{python} -#| label: Q2 -#| code-summary: Read and format data -# Include and execute your code here - - -``` - -_include figures in chunks and discuss your findings in the figure._ - -```{python} -#| label: Q2 chart -#| code-summary: plot example -#| fig-cap: "My useless chart" -#| fig-align: center -# Include and execute your code here -chart = px.bar(df.head(200), - x="name", - y="AK" -) -chart.show() -``` - - -```{python} -#| label: Q2 table -#| code-summary: table example -#| tbl-cap: "Not much of a table" -#| tbl-cap-location: top -# Include and execute your code here -mydat = df.head(1000)\ - .groupby('year')\ - .sum()\ - .reset_index()\ - .tail(10)\ - .filter(["year", "AK","AR"]) - -display(mydat) - -``` - - -## QUESTION|TASK 3 - -__COPY PASTE QUESTION|TASK 3 FROM THE PROJECT HERE__ - -_type your results and analysis here_ - -```{python} -#| label: Q3 -#| code-summary: Read and format data -# Include and execute your code here - - -``` - -_include figures in chunks and discuss your findings in the figure._ - -```{python} -#| label: Q3 chart -#| code-summary: plot example -#| fig-cap: "My useless chart" -#| fig-align: center -# Include and execute your code here -chart = px.bar(df.head(200), - x="name", - y="AK" -) -chart.show() -``` - - -```{python} -#| label: Q3 table -#| code-summary: table example -#| tbl-cap: "Not much of a table" -#| tbl-cap-location: top -# Include and execute your code here -mydat = df.head(1000)\ - .groupby('year')\ - .sum()\ - .reset_index()\ - .tail(10)\ - .filter(["year", "AK","AR"]) - -display(mydat) - -``` +### Paste in a template diff --git a/Projects/project2.qmd b/Projects/project2.qmd index 2d4622a..f2154af 100644 --- a/Projects/project2.qmd +++ b/Projects/project2.qmd @@ -25,171 +25,4 @@ execute: --- -### Uncomment the entire section to use this template - - +### Paste in a template diff --git a/Projects/project3.qmd b/Projects/project3.qmd index 2d4622a..f2154af 100644 --- a/Projects/project3.qmd +++ b/Projects/project3.qmd @@ -25,171 +25,4 @@ execute: --- -### Uncomment the entire section to use this template - - +### Paste in a template diff --git a/Projects/project4.qmd b/Projects/project4.qmd index 94db098..f2154af 100644 --- a/Projects/project4.qmd +++ b/Projects/project4.qmd @@ -25,172 +25,4 @@ execute: --- - -### Uncomment the entire section to use this template - - +### Paste in a template diff --git a/Projects/project5.qmd b/Projects/project5.qmd index 2d4622a..f2154af 100644 --- a/Projects/project5.qmd +++ b/Projects/project5.qmd @@ -25,171 +25,4 @@ execute: --- -### Uncomment the entire section to use this template - - +### Paste in a template diff --git a/Templates/DS250_Template.qmd b/Templates/DS250_Template.qmd new file mode 100644 index 0000000..2d4622a --- /dev/null +++ b/Templates/DS250_Template.qmd @@ -0,0 +1,195 @@ +--- +title: "Client Report - [Insert Project Title]" +subtitle: "Course DS 250" +author: "[STUDENT NAME]" +format: + html: + self-contained: true + page-layout: full + title-block-banner: true + toc: true + toc-depth: 3 + toc-location: body + number-sections: false + html-math-method: katex + code-fold: true + code-summary: "Show the code" + code-overflow: wrap + code-copy: hover + code-tools: + source: false + toggle: true + caption: See code +execute: + warning: false + +--- + +### Uncomment the entire section to use this template + + diff --git a/Templates/DS350_Template.qmd b/Templates/DS350_Template.qmd new file mode 100644 index 0000000..cf3b03c --- /dev/null +++ b/Templates/DS350_Template.qmd @@ -0,0 +1,28 @@ +--- +title: "Client Report - [Insert Project Title]" +subtitle: "Course DS 250" +author: "[STUDENT NAME]" +format: + html: + self-contained: true + page-layout: full + title-block-banner: true + toc: true + toc-depth: 3 + toc-location: body + number-sections: false + html-math-method: katex + code-fold: true + code-summary: "Show the code" + code-overflow: wrap + code-copy: hover + code-tools: + source: false + toggle: true + caption: See code +execute: + warning: false + +--- + +### TODO: Update with template from Paul diff --git a/_site/cleansing.html b/_site/cleansing.html index f4658e1..83f85a1 100644 --- a/_site/cleansing.html +++ b/_site/cleansing.html @@ -2,7 +2,7 @@ - + @@ -48,7 +48,13 @@ "collapse-after": 3, "panel-placement": "end", "type": "overlay", - "limit": 20, + "limit": 50, + "keyboard-shortcut": [ + "f", + "/", + "s" + ], + "show-item-context": false, "language": { "search-no-results-text": "No results", "search-matching-documents-text": "matching documents", @@ -57,6 +63,7 @@ "search-more-match-text": "more match in this document", "search-more-matches-text": "more matches in this document", "search-clear-button-title": "Clear", + "search-text-placeholder": "", "search-detached-cancel-button-title": "Cancel", "search-submit-button-title": "Submit", "search-label": "Search" @@ -67,13 +74,13 @@ - +
-
- -
@@ -222,16 +179,52 @@

about me

+ +

Title 1 Header

Title 2 Header

MarkDown Basics

+
+
+
+

%% [markdown]

+
+
+

+
+
+

title: Palmer Penguins

+
+
+

author: Norah Jones

+
+
+

date: 3/12/23

+
+
+

+
+
+

%%

+

#| echo: false import pandas as pd df = pd.read_csv(“palmer-penguins.csv”)

+
+
+

%% [markdown]

+

““” ## Exploring the data

+

See ?@fig-bill-sizes for an exploration of bill sizes by species. ““”

+
+
+

%%

+

#| label: fig-bill-sizes #| fig-cap: Bill Sizes by Species

+

import matplotlib.pyplot as plt
+import seaborn as sns

+

g = sns.FacetGrid(df, hue=“species”, height=3, aspect=3.5/1.5) g.map(plt.scatter, “bill_length_mm”, “bill_depth_mm”).add_legend()

-
Back to top @@ -278,6 +271,33 @@

Title 2 Header

} } } + const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => { + const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light'; + const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark'; + let newTheme = ''; + if(darkModeDefault) { + newTheme = isAlternate ? baseTheme : alternateTheme; + } else { + newTheme = isAlternate ? alternateTheme : baseTheme; + } + const changeGiscusTheme = () => { + // From: https://github.com/giscus/giscus/issues/336 + const sendMessage = (message) => { + const iframe = document.querySelector('iframe.giscus-frame'); + if (!iframe) return; + iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); + } + sendMessage({ + setConfig: { + theme: newTheme + } + }); + } + const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null; + if (isGiscussLoaded) { + changeGiscusTheme(); + } + } const toggleColorMode = (alternate) => { // Switch the stylesheets const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate'); @@ -344,13 +364,15 @@

Title 2 Header

return localAlternateSentinel; } } - let localAlternateSentinel = 'default'; + const darkModeDefault = false; + let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default'; // Dark / light mode switch window.quartoToggleColorScheme = () => { // Read the current dark / light value let toAlternate = !hasAlternateSentinel(); toggleColorMode(toAlternate); setStyleSentinel(toAlternate); + toggleGiscusIfUsed(toAlternate, darkModeDefault); }; // Ensure there is a toggle, if there isn't float one in the top right if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { @@ -429,10 +451,27 @@

Title 2 Header

// clear code selection e.clearSelection(); }); - function tippyHover(el, contentFn) { + var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//); + var mailtoRegex = new RegExp(/^mailto:/); + var filterRegex = new RegExp('/' + window.location.host + '/'); + var isInternal = (href) => { + return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href); + } + // Inspect non-navigation links and adorn them if external + var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool)'); + for (var i=0; iTitle 2 Header interactive: true, interactiveBorder: 10, theme: 'quarto', - placement: 'bottom-start' + placement: 'bottom-start', }; + if (contentFn) { + config.content = contentFn; + } + if (onTriggerFn) { + config.onTrigger = onTriggerFn; + } + if (onUntriggerFn) { + config.onUntrigger = onUntriggerFn; + } window.tippy(el, config); } const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]'); @@ -455,7 +503,130 @@

Title 2 Header

try { href = new URL(href).hash; } catch {} const id = href.replace(/^#\/?/, ""); const note = window.document.getElementById(id); - return note.innerHTML; + if (note) { + return note.innerHTML; + } else { + return ""; + } + }); + } + const xrefs = window.document.querySelectorAll('a.quarto-xref'); + const processXRef = (id, note) => { + // Strip column container classes + const stripColumnClz = (el) => { + el.classList.remove("page-full", "page-columns"); + if (el.children) { + for (const child of el.children) { + stripColumnClz(child); + } + } + } + stripColumnClz(note) + if (id === null || id.startsWith('sec-')) { + // Special case sections, only their first couple elements + const container = document.createElement("div"); + if (note.children && note.children.length > 2) { + container.appendChild(note.children[0].cloneNode(true)); + for (let i = 1; i < note.children.length; i++) { + const child = note.children[i]; + if (child.tagName === "P" && child.innerText === "") { + continue; + } else { + container.appendChild(child.cloneNode(true)); + break; + } + } + if (window.Quarto?.typesetMath) { + window.Quarto.typesetMath(container); + } + return container.innerHTML + } else { + if (window.Quarto?.typesetMath) { + window.Quarto.typesetMath(note); + } + return note.innerHTML; + } + } else { + // Remove any anchor links if they are present + const anchorLink = note.querySelector('a.anchorjs-link'); + if (anchorLink) { + anchorLink.remove(); + } + if (window.Quarto?.typesetMath) { + window.Quarto.typesetMath(note); + } + // TODO in 1.5, we should make sure this works without a callout special case + if (note.classList.contains("callout")) { + return note.outerHTML; + } else { + return note.innerHTML; + } + } + } + for (var i=0; i res.text()) + .then(html => { + const parser = new DOMParser(); + const htmlDoc = parser.parseFromString(html, "text/html"); + const note = htmlDoc.getElementById(id); + if (note !== null) { + const html = processXRef(id, note); + instance.setContent(html); + } + }).finally(() => { + instance.enable(); + instance.show(); + }); + } + } else { + // See if we can fetch a full url (with no hash to target) + // This is a special case and we should probably do some content thinning / targeting + fetch(url) + .then(res => res.text()) + .then(html => { + const parser = new DOMParser(); + const htmlDoc = parser.parseFromString(html, "text/html"); + const note = htmlDoc.querySelector('main.content'); + if (note !== null) { + // This should only happen for chapter cross references + // (since there is no id in the URL) + // remove the first header + if (note.children.length > 0 && note.children[0].tagName === "HEADER") { + note.children[0].remove(); + } + const html = processXRef(null, note); + instance.setContent(html); + } + }).finally(() => { + instance.enable(); + instance.show(); + }); + } + }, function(instance) { }); } let selectedAnnoteEl; @@ -499,6 +670,7 @@

Title 2 Header

} div.style.top = top - 2 + "px"; div.style.height = height + 4 + "px"; + div.style.left = 0; let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter"); if (gutterDiv === null) { gutterDiv = window.document.createElement("div"); @@ -524,6 +696,32 @@

Title 2 Header

}); selectedAnnoteEl = undefined; }; + // Handle positioning of the toggle + window.addEventListener( + "resize", + throttle(() => { + elRect = undefined; + if (selectedAnnoteEl) { + selectCodeLines(selectedAnnoteEl); + } + }, 10) + ); + function throttle(fn, ms) { + let throttle = false; + let timer; + return (...args) => { + if(!throttle) { // first call gets through + fn.apply(this, args); + throttle = true; + } else { // all the others get throttled + if(timer) clearTimeout(timer); // cancel #2 + timer = setTimeout(() => { + fn.apply(this, args); + timer = throttle = false; + }, ms); + } + }; + } // Attach click handler to the DT const annoteDls = window.document.querySelectorAll('dt[data-target-cell]'); for (const annoteDlNode of annoteDls) { @@ -586,7 +784,9 @@

Title 2 Header