Lab 01: Setup, RMarkdown

Welcome!

Welcome to STAT 33B! I’ll be your uGSI, Jakob Sorensen.

  • Contact: jakobsorensen@berkeley.edu

  • Sections:

    • 9 AM - 10 AM and 10 AM - 11 AM in Evans 342

    • 2 PM - 3 PM and 3 PM - 4 PM in Cory 289

  • Office Hours: TBD in Evans 434

Expectations

This is a 1 unit class.

  • Weekly Lab (13 total)

  • Monthly Quiz (3 total)

  • Biweekly – every 2 weeks – Homework (6 total)

  • Final Exam

Our Lab

Here’s the tentative structure for our labs.

  • For the first 15-20 minutes, I’ll lecture briefly on select topics from the week’s material.

  • Afterwards, you are free to work on the lab, and I’m available to help.

Installing R and RStudio

Please install R and RStudio now if you haven’t already.

  • R: https://www.r-project.org/

  • RStudio: https://www.rstudio.com/products/rstudio/

RStudio Demo

Separate window.

RMarkdown

RMarkdown (.rmd) is file type that allows us to merge,

  • Formatted written material,
  • and R code

into a single document.

This presentation is using a variant of RMarkdown!

This is RMarkdown?

## RMarkdown

RMarkdown (``.rmd``) is file type that allows us to merge,

-   Formatted written material,
-   and **R** code

into a single document.

RMarkdown - Basic Formatting

Software like Microsoft Word and Google Docs hides the underlying format representation.

In a markup language, we embed the formatting alongside the text.

An Example: HTML (HyperText Markup Language)

This is <b>bold!</b> But this is merely <i>emphasized!</i>

Another Example: LaTeX

This is \textbf{bold!} But this is merely \textit{emphasized!}

RMarkdown

This is **bold!** But this is merely _emphasized!_

Headers

Aren’t headers…

… just lovely?

## Headers

### Aren't headers...

#### ... just lovely?

\(N\) # characters denotes an \(Nth\) level header.

Font Face: Bold

I’m bold and uncontrolled!

## Font Face: **Bold**

I'm **bold** and **uncontrolled!**

Surrounding text with ** at each end makes it bold.

Font Face: Italics

Don’t eat that burger! Don’t eat that burger!

## Font Face: _Italics_

Don't eat _that_ burger! Don't _eat_ that burger!

Surrounding text with _ at each end italicizes it.

Font Face: Plain Text or Code

The variable x passed into function main.

## Font Face: ``Plain Text or Code``

The variable ``x`` passed into function ``main``.

Surrounding text with `` at each end makes it plain text (like code).

And more…

We can also embed lists, tables, images, and many other components!

Code Chunks

We include code in what we call code chunks. A basic example in this document:

```{r}
print("Hello, World!")

x <- 3
y <- 5
print(paste("x + y =", x + y))
```
[1] "Hello, World!"
[1] "x + y = 8"

Note that we’ve included the output of our code directly in the document.

Code Chunk: Plot Example

```{r}
plot(1:10, seq(10, 100, 10), type = "l", 
     xlab = "Time Spent Studying (Hours)", ylab = "Quiz Grade (%)")
```

Knitting

Going from the plain text format (.rmd) to a presentation format (.pdf, .html) is called knitting the document.

RMarkdown Demo

Separate window.