Skip to content

Commit

Permalink
Adds RMarkdown website files
Browse files Browse the repository at this point in the history
  • Loading branch information
topfunky committed Dec 2, 2020
1 parent 99a381d commit 9b6b16b
Show file tree
Hide file tree
Showing 41 changed files with 920 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.Rhistory
.RData
.Ruserdata
data/*/dvoa.html
data/*/dvoa.html
public/*
21 changes: 21 additions & 0 deletions content/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
date: "2016-05-05T21:48:51-07:00"
title: About
---

```{r include=FALSE}
source("nfl_expected_wins.R", local = knitr::knit_global())
# or sys.source("your-script.R", envir = knitr::knit_global())
```

This is a "hello world" example website for the [**blogdown**](https://github.com/rstudio/blogdown) package. The theme was forked from [@jrutheiser/hugo-lithium-theme](https://github.com/jrutheiser/hugo-lithium-theme) and modified by [Yihui Xie](https://github.com/yihui/hugo-lithium).

asotnehu asnoteh uasontheu asotneuh asoeuh asontehu asontehu asontheu asoeuh

```{r fig.cap="Chart"}
training_years <- c(2015, 2019)
all_years <- c(2002, 2020)
data <- load_data_and_build_model(training_years, all_years)
plot <- plot_wins(data, all_years[1], all_years[2])
```
6 changes: 6 additions & 0 deletions content/post/2015-01-01-lorem-ipsum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
date: "2015-01-01T13:09:13-06:00"
title: Lorem Ipsum
---

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore _magna aliqua_. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
24 changes: 24 additions & 0 deletions content/post/2015-07-23-r-rmarkdown/index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Hello R Markdown"
author: "Frida Gomam"
date: 2015-07-23T21:13:14-05:00
categories: ["R"]
tags: ["R Markdown", "plot", "regression"]
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE)
knitr::opts_knit$set(root.dir = "../../../")
```

NFL

```{r fig.cap="Chart", fig.height=32}
sys.source("nfl_expected_wins.R", envir = knitr::knit_global())
training_years <- c(2015, 2019)
all_years <- c(2002, 2020)
data <- load_data_and_build_model(training_years, all_years)
plot <- plot_wins(data, all_years[1], all_years[2])
plot
```
84 changes: 84 additions & 0 deletions content/post/2015-07-23-r-rmarkdown/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: "Hello R Markdown"
author: "Frida Gomam"
date: 2015-07-23T21:13:14-05:00
categories: ["R"]
tags: ["R Markdown", "plot", "regression"]
---

<link href="index_files/anchor-sections/anchor-sections.css" rel="stylesheet" />
<script src="index_files/anchor-sections/anchor-sections.js"></script>


<p>NFL</p>
<pre class="r"><code>sys.source(&quot;nfl_expected_wins.R&quot;, envir = knitr::knit_global())
## ── Attaching packages ────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ───────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## Loading required package: xml2
##
## Attaching package: &#39;rvest&#39;
## The following object is masked from &#39;package:purrr&#39;:
##
## pluck
## The following object is masked from &#39;package:readr&#39;:
##
## guess_encoding
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
## be found for family &quot;Sentinel&quot;
training_years &lt;- c(2015, 2019)
all_years &lt;- c(2002, 2020)

data &lt;- load_data_and_build_model(training_years, all_years)
plot &lt;- plot_wins(data, all_years[1], all_years[2])
plot</code></pre>
<div class="figure"><span id="fig:unnamed-chunk-1"></span>
<img src="index_files/figure-html/unnamed-chunk-1-1.png" alt="Chart" width="672" />
<p class="caption">
Figure 1: Chart
</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Styles for section anchors */
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
a.anchor-section::before {content: '#';}
.hasAnchor:hover a.anchor-section {visibility: visible;}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
document.addEventListener('DOMContentLoaded', function() {
// Do nothing if AnchorJS is used
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
return;
}

const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');

// Do nothing if sections are already anchored
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
return null;
}

// Use section id when pandoc runs with --section-divs
const section_id = function(x) {
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
? x.id : '');
};

// Add anchors
h.forEach(function(x) {
const id = x.id || section_id(x.parentElement);
if (id === '') {
return null;
}
let anchor = document.createElement('a');
anchor.href = '#' + id;
anchor.classList = ['anchor-section'];
x.classList.add('hasAnchor');
x.appendChild(anchor);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions content/post/2016-12-30-hello-markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
date: "2016-12-30T21:49:57-07:00"
title: A Plain Markdown Post
---

NFL

```{r include=FALSE}
source("nfl_expected_wins.R", local = knitr::knit_global())
# or sys.source("your-script.R", envir = knitr::knit_global())
```

This is a "hello world" example website for the [**blogdown**](https://github.com/rstudio/blogdown) package. The theme was forked from [@jrutheiser/hugo-lithium-theme](https://github.com/jrutheiser/hugo-lithium-theme) and modified by [Yihui Xie](https://github.com/yihui/hugo-lithium).

asotnehu asnoteh uasontheu asotneuh asoeuh asontehu asontehu asontheu asoeuh

```{r fig.cap="Chart"}
training_years <- c(2015, 2019)
all_years <- c(2002, 2020)
data <- load_data_and_build_model(training_years, all_years)
plot_wins(data, all_years[1], all_years[2])
```


This is a post written in plain Markdown (`*.md`) instead of R Markdown (`*.Rmd`). The major differences are:

1. You cannot run any R code in a plain Markdown document, whereas in an R Markdown document, you can embed R code chunks (```` ```{r} ````);
2. A plain Markdown post is rendered through [Blackfriday](https://gohugo.io/overview/configuration/), and an R Markdown document is compiled by [**rmarkdown**](http://rmarkdown.rstudio.com) and [Pandoc](http://pandoc.org).

There are many differences in syntax between Blackfriday's Markdown and Pandoc's Markdown. For example, you can write a task list with Blackfriday but not with Pandoc:

- [x] Write an R package.
- [ ] Write a book.
- [ ] ...
- [ ] Profit!

Similarly, Blackfriday does not support LaTeX math and Pandoc does. I have added the MathJax support to this theme ([hugo-lithium](https://github.com/yihui/hugo-lithium)) but there is a caveat for plain Markdown posts: you have to include math expressions in a pair of backticks (inline: `` `$ $` ``; display style: `` `$$ $$` ``), e.g., `$S_n = \sum_{i=1}^n X_i$`.^[This is because we have to protect the math expressions from being interpreted as Markdown. You may not need the backticks if your math expression does not contain any special Markdown syntax such as underscores or asterisks, but it is always a safer choice to use backticks. When you happen to have a pair of literal dollar signs inside the same element, you can escape one dollar sign, e.g., `\$50 and $100` renders "\$50 and $100".] For R Markdown posts, you do not need the backticks, because Pandoc can identify and process math expressions.

When creating a new post, you have to decide whether the post format is Markdown or R Markdown, and this can be done via the `ext` argument of the function `blogdown::new_post()`, e.g.

```r
blogdown::new_post("Post Title", ext = '.Rmd')
```
3 changes: 3 additions & 0 deletions index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
site: blogdown:::blogdown_site
---
4 changes: 4 additions & 0 deletions themes/hugo-lithium/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
20 changes: 20 additions & 0 deletions themes/hugo-lithium/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 Jonathan Rutheiser, 2016 - 2017 Yihui Xie

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 changes: 44 additions & 0 deletions themes/hugo-lithium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Hugo Lithium

A simple responsive blog theme for [Hugo](https://gohugo.io/) forked from https://github.com/jrutheiser/hugo-lithium-theme with modifications to make it work better with [**blogdown**](https://github.com/rstudio/blogdown).

The easiest way to get started is to create a new (empty) RStudio project, then

```r
devtools::install_github('rstudio/blogdown') # install blogdown
blogdown::new_site(theme = 'yihui/hugo-lithium')
```

Then you should be able to see an example website launched in the RStudio Viewer.

For the full documentation, please see this section in the **blogdown** book: https://bookdown.org/yihui/blogdown/themes.html

## Features

- Blog
- Responsive
- Disqus
- Google Analytics
- Google web fonts (Merriweather and Lato)
- MathJax
- highlight.js

## Changes

The main changes I made to the original hugo-lithium-theme are:

1. Added support for [MathJax](https://bookdown.org/yihui/blogdown/output-format.html) (for rendering LaTeX math expressions) and highlight.js (for syntax highlighting).

- For both libraries, you can specify the CDN host (e.g., CloudFlare, BootCDN, ...).

- For highlight.js, you can specify additional languages (e.g., `r`, `yaml`, `tex`, ...).

1. Added Google web fonts (embedded in the theme so that visitors from countries where Google is banned can still see the typefaces).

1. Improved Hugo's built-in Disqus template, so that you can actually view the comments even when you are previewing the website locally.

1. Replaced the variable `.Permalink` with `.RelPermalink`, and function `absURL` with `relURL` where necessary. It is a bad idea to use full absolute links (with the protocol and domain) in general. For example, `.Permalink` and `absURL` may generate URLs of the form `http://www.example.com/foo/bar.html`, but `/foo/bar.html` is more portable.

## License

The original hugo-lithium-theme was released by Jonathan Rutheiser under [the MIT License](https://github.com/jrutheiser/hugo-lithium-theme/blob/master/LICENSE.md). The modified version in this repository is also released under MIT.
4 changes: 4 additions & 0 deletions themes/hugo-lithium/archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: ''
date: ''
---
42 changes: 42 additions & 0 deletions themes/hugo-lithium/exampleSite/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
baseurl = "/"
languageCode = "en-us"
title = "A Hugo website"
theme = "hugo-lithium"
googleAnalytics = ""
disqusShortname = ""
ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_cache$", "\\.knit\\.md$", "\\.utf8\\.md$"]

[permalinks]
post = "/:year/:month/:day/:slug/"

[[menu.main]]
name = "About"
url = "/about/"
[[menu.main]]
name = "GitHub"
url = "https://github.com/rstudio/blogdown"
[[menu.main]]
name = "Twitter"
url = "https://twitter.com/rstudio"

[params]
description = "A website built through Hugo and blogdown."

# options for highlight.js (version, additional languages, and theme)
highlightjsVersion = "9.12.0"
highlightjsCDN = "//cdnjs.cloudflare.com/ajax/libs"
highlightjsLang = ["r", "yaml"]
highlightjsTheme = "github"

MathJaxCDN = "//cdnjs.cloudflare.com/ajax/libs"
MathJaxVersion = "2.7.5"

# path to the favicon, under "static"
favicon = "favicon.ico"

[params.logo]
url = "logo.png"
width = 50
height = 50
alt = "Logo"

6 changes: 6 additions & 0 deletions themes/hugo-lithium/exampleSite/content/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "About"
date: "2016-05-05T21:48:51-07:00"
---

This is a "hello world" example website for the [**blogdown**](https://github.com/rstudio/blogdown) package. The theme was forked from [@jrutheiser/hugo-lithium-theme](https://github.com/jrutheiser/hugo-lithium-theme) and modified by [Yihui Xie](https://github.com/yihui/hugo-lithium).
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Lorem Ipsum"
date: 2015-01-01T13:09:13-06:00
---

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore _magna aliqua_. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "A Plain Markdown Post"
date: "2016-12-30T21:49:57-07:00"
---

This is a post written in plain Markdown (`*.md`) instead of R Markdown (`*.Rmd`). The major differences are:

1. You cannot run any R code in a plain Markdown document, whereas in an R Markdown document, you can embed R code chunks (```` ```{r} ````);
2. A plain Markdown post is rendered through [Blackfriday](https://gohugo.io/overview/configuration/), and an R Markdown document is compiled by [**rmarkdown**](http://rmarkdown.rstudio.com) and [Pandoc](http://pandoc.org).

There are many differences in syntax between Blackfriday's Markdown and Pandoc's Markdown. For example, you can write a task list with Blackfriday but not with Pandoc:

- [x] Write an R package.
- [ ] Write a book.
- [ ] ...
- [ ] Profit!

Similarly, Blackfriday does not support LaTeX math and Pandoc does. I have added the MathJax support to this theme ([hugo-lithium](https://github.com/yihui/hugo-lithium)) but there is a caveat for plain Markdown posts: you have to include math expressions in a pair of backticks (inline: `` `$ $` ``; display style: `` `$$ $$` ``), e.g., `$S_n = \sum_{i=1}^n X_i$`.^[This is because we have to protect the math expressions from being interpreted as Markdown. You may not need the backticks if your math expression does not contain any special Markdown syntax such as underscores or asterisks, but it is always a safer choice to use backticks. When you happen to have a pair of literal dollar signs inside the same element, you can escape one dollar sign, e.g., `\$50 and $100` renders "\$50 and $100".] For R Markdown posts, you do not need the backticks, because Pandoc can identify and process math expressions.

When creating a new post, you have to decide whether the post format is Markdown or R Markdown, and this can be done via the `ext` argument of the function `blogdown::new_post()`, e.g.

```r
blogdown::new_post("Post Title", ext = '.Rmd')
```
Empty file.
Loading

0 comments on commit 9b6b16b

Please sign in to comment.