favstats / rmarkdown_demo_chat

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rmarkdown Demo Chat with PhDs

Why Rmarkdown?

  • Code, results, and text in the same document
  • Your results and plots are automatically generated from your data, so your documents can be easily updated if your data changes
  • Outputs can be directly deployed online
    • Integrates nicely with GitHub Pages and other hosting services
  • Reproducible Workflow - from raw data over analysis to presentation

YAML Header

A YAML header is a set of key-value pairs at the start of your file. The YAML header includes meta-information about your Rmarkdown document. For example whether the output should be an HTML or a PDF document. Begin and end the header with a line of three dashes (- - -)

---
title: "Rmarkdown Workshop"
subtitle: "A basic Introduction"
author: "Fabio Votta"
output: html_document
---

Possible outputs:

  • output: html_document
  • output: pdf_document
  • output: word_document
  • output: beamer_presentation
  • output: ioslides_presentation

Rmarkdown Syntax

CODING EXAMPLE

italics and bold

inline code

sub2/superscript2

strikethrough

escaped: * _ \

endash: –, emdash: —

blockquote

Header 1

Header 2

Line break: End line with 2+ spaces, or backslash: Roses are red Violets are blue

Roses are red
Violets are blue

CODING EXAMPLE

This… - unordered list - sub-item - sub-item 2 - sub-sub-item

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

inline-math: A = π * r2

math-block: A = π * r2

text for hyperlink

A footnote [1]

Introducing a Code Chunk

A Special Kind of Chunk

In a setup chunk, one usually sets global options for the entire document.

Normally, an R Markdown document starts with this chunk.

knitr::opts_chunk$set sets default options for all chunks.

## Sets Global Options
knitr::opts_chunk$set(echo = T, warning = F, message = F)
option default effect
eval TRUE Whether to evaluate the code and include its results
echo TRUE Whether to display code along with its results
warning TRUE Whether to display warnings
error FALSE Whether to display errors
message TRUE Whether to display messages
tidy FALSE Whether to reformat code in a tidy way when displaying it
results “markup” “markup”, “asis”, “hold”, or “hide”
cache FALSE Whether to cache results for future renders
comment “##” Comment character to preface results with
fig.width 7 Width in inches for plots created in chunk
fig.height 7 Height in inches for plots created in chunk

Including Tables

cars %>% 
  head() %>% 
  knitr::kable()
speed dist
4 2
4 10
7 4
7 22
8 16
9 10

The kable function within knitr produces neat tables out of dataframes. A number of other packages are available for making pretty tables, see rmarkdown.rstudio.com.

result <- 4 + 4

Inside your text you can include code with the syntax 8.

Links for futher learning:

[1] here is the footnote text.

About


Languages

Language:HTML 100.0%