Testing the features

Table of Contents

Display math:

\[Y_{i+1} = \lambda_{i+1}\]

$$ Y_{i+1} = \lambda_{i+1} $$

\[ Y_{i+1} = \lambda_{i+1} \]

\\[ Y_{i+1} = \lambda_{i+1} \\]

Inline math: $Y_{i+1} = \lambda_{i+1}$, \( Y_{i+1} = \lambda_{i+1} \), \\( Y_{i+1} = \lambda_{i+1} \\), \(Y_{i+1} = \lambda_{i+1}\), $$Y_{i+1} = \lambda_{i+1}$$, \[ Y_{i+1} = \lambda_{i+1} \].

Solution to MathJax parsing problem:

  • Use $$ for display and inline math.
  • Use $ for inline math when subscript does not need braces, because: $Y_i$, $Y_100$, $Y_{i,j}$, $Y_{i}$, $Y_{i+1}$, $Y_{100}$, should look like \(Y_i\), \(Y_100\), \(Y_{i,j}\), \(Y_{i}\), \(Y_{i+1}\), \(Y_{100}\).
  • Use empty line above and below display math, so that display math is defined as newline+$$ and $$+newline.
  • Inline math is then defined as: non-whitespace+$$ or $$+non-whitespace.

RStudo parsing before knitr should take care of these:

  • replace triple backtick and r with {r}
  • replace inline $$ with $

Note: slides work OK, no need to tweak inline math

Always start with a header

This Rmd file demonstrates how we intend to host text/math/code on the website. We have 3 aims:

  1. Folks can read the text/code/math on the web and copy/paste for themselves. The web design is taken care of GitHub and jekyll pages (including Markdown formatting, liquid templating, syntax highlight and MathJax notation).
  2. The file opens up in Rstudio, code runs natively in R and can be turned into some other format (like pdf, html, slides, etc.), while still properly displaying text formatting, code (with syntax highlight), and math (using local MathJax client side rendering).
  3. We can delop text/code/math without polluting our workspace with ugly html stuff.

Workflow

  1. Create a new Rmd (R Markdown)file.
  2. Use the source of this file (test.Rmd) as template, espacially as concerns the yaml header. That is the lines between the --- triple dashes. It tells the website how to display the content, while it gives directions to the knitr R package about how to turn the code into html. For different output, the output tag value can be edited. The only important thing really is the layout.
  3. Following the syntax rules below.
  4. Save and commit to the datacloning.github.io project (or create a pull request). Make sure to push to the master branch. Of course, we need to figure out placement in the directory tree – this is under construction.
  5. This way the source code can be edited online as well through GitHub. Any changes should be visible on the website almost instantly (might have to refresh the browser).

Showcase

This is plain text. This is footnote1 and this is reference Smith 2000. References can be treated as abbreviations, but that is not too $\LaTeX$ friendly, like Smith 2000

Footnotes

This is [an example][^id] reference-style link. [^id]: http://example.com/ “Optional Title Here”

This is some text1. Other text2. This is some text3. Other text4.

Formatting

This text is italics and italics, while this is bold and bold.

Mathematics

For superscript$^2$, use inline math, such as these: $A = \pi*r^{2}$ (written as $A = \pi*r^{2}$).

\[a = \sqrt{b^2 + c^2}\]

Test if single dollar sign works: $a^2 = \sum{z}$.
Forced new line.

This link takes you to a site.

Header 1

Header 2

Header 3

Header 4

Header 5
Header 6

endash: –

emdash: —

ellipsis: …

image: Alt text

horizontal rule (or slide break):


Lists

  • unordered list
  • item 2
  • sub-item 1
  • sub-item 2
  1. ordered list
  2. item 2
    • sub-item 1
    • sub-item 2

Definition lists

Term 1

Definition 1

Term 2 with inline markup

Definition 2

{ some code, part of Definition 2 }

Third paragraph of definition 2.

Table formatting

Table Header Second Header
Table Cell Cell 2
Cell 3 Cell 4

Another table:

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Code blocks

Make a code chunk with three back ticks followed by R (this helps figuring out highlight rules). End the chunk with three back ticks:

paste("Hello", "World!")

Place code inline with a single back ticks, like this paste("Hello", "World!").

Few more code blocks

Using nohighlight:

lapply <-
function (X, FUN, ...) 
{
    FUN <- match.fun(FUN)
    if (!is.vector(X) || is.object(X)) 
        X <- as.list(X)
    .Internal(lapply(X, FUN))
}
a <- c(1,2,3) # x y z
b <- c(TRUE, FALSE)
## k c z
k <- c("a", "b")

Using blank:

lapply <-
function (X, FUN, ...) 
{
    FUN <- match.fun(FUN)
    if (!is.vector(X) || is.object(X)) 
        X <- as.list(X)
    .Internal(lapply(X, FUN))
}
a <- c(1,2,3) # x y z
b <- c(TRUE, FALSE)
## k c z
k <- c("a", "b")

Using r:

lapply <-
function (X, FUN, ...) 
{
    FUN <- match.fun(FUN)
    if (!is.vector(X) || is.object(X)) 
        X <- as.list(X)
    .Internal(lapply(X, FUN))
}
a <- c(1,2,3) # x y z
b <- c(TRUE, FALSE)
## k c z
k <- c("a", "b")

GFM options (that don’t work, but left here for testing anyway):

superscript^2^

~strikeout~

  • done
  • to do.

  • done
  • to do.

This is a paragraph.

A nested blockquote.

Headers work

  • lists too

and all other block-level elements

\[\begin{align*} & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right) = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\ & (x_1, \ldots, x_n) \left( \begin{array}{ccc} \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\ \vdots & \ddots & \vdots \\ \phi(e_n, e_1) & \cdots & \phi(e_n, e_n) \end{array} \right) \left( \begin{array}{c} y_1 \\ \vdots \\ y_n \end{array} \right) \end{align*}\]

This is a text with light and strong emphasis. This is emphasized as well. This does _not_ work. This does __not__ work either.

This is a R code fragment x = 1 + c(a, 2)

This is some code. A link and some tools.

Bootstrap tags

These tags can be used to track changes in code:

  • This line of text is meant to be treated as deleted text.
  • This line of text is meant to be treated as no longer accurate.
  • This line of text is meant to be treated as an addition to the document.
  • This line of text will render as underlined

Other cool features

  • attr
  • Lowercased text.

  • Uppercased text.

  • Capitalized text.

  • y = mx + b

These backgrounds can be used to highlight topics

  primary

  primary

  success

  info

  warning

  danger

Emphasis classes

Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.

Nullam id dolor id nibh ultricies vehicula ut id elit.

Etiam porta sem malesuada magna mollis euismod.

Donec ullamcorper nulla non metus auctor fringilla.

Duis mollis, est non commodo luctus, nisi erat porttitor ligula.

Maecenas sed diam eget risus varius blandit sit amet non magna.

Use headings in quote block?

Why not!

That is the whole point!

Also:

  Warning

This is a warning.

References

Smith 2000. The best paper ever. Journal, 1-2.

1. Footnote 1.

Kramdown syntax guide: http://kramdown.gettalong.org/syntax.html

Bootswatch

#### Warning! Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue.
# Jumbotron This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.

Learn more

Panel primary
Panel content
paste("Hello", "World!")
Panel primary
Panel content
paste("Hello", "World!")
Look, I'm in a well!
## defining a website compatible palette
dcpal_flatly <- list(
    "red"="#c7254e",
    "palered"="#f9f2f4",
    "primary"="#2c3e50",
    "success"="#18bc9c",
    "info"="#3498db",
    "warning"="#f39c12",
    "danger"="#e74c3c",
    "pre_col"="#7b8a8b",
    "pre_bg"="#ecf0f1",
    "pre_border"= "#cccccc"
)
dcpal_reds <- colorRampPalette(c("#f9f2f4", "#c7254e"))
dcpal_ogrd <- colorRampPalette(c("#f39c12", "#e74c3c"))
dcpal_grbu <- colorRampPalette(c("#18bc9c", 
    "#3498db", "#2c3e50"))

op <- par(las=2, mar=c(6,5,2,2), mfrow=c(2,2))
barplot(1:length(dcpal_flatly), 
    names=names(dcpal_flatly), 
    border=dcpal_flatly$pre_border,
    col=unlist(dcpal_flatly))
barplot(1:10, col=dcpal_reds(10), main="Reds")
barplot(1:10, col=dcpal_grbu(10), main="Green-Blue")
barplot(1:10, col=dcpal_ogrd(10), main="Orange-Red")
par(op)

Learning Objectives

  • Learning objective 1
  • Learning objective 2
a <- list("a", 1, FALSE, function(x) x+1) # no
## yes
a <- list("a", 1, FALSE, function(x) x+1) # no
## yes
  1. Some crazy footnote definition. 

  2. Blockquotes can be in a footnote.

    as well as code blocks
    

    or, naturally, simple paragraphs. 

  3. no code block here (spaces are stripped away) 

  4. this is now a code block (8 spaces indentation)