Lab 1: Welcome to Posit Cloud!

Author

Your Name Here!

Quarto

This is a Quarto document!

Quarto is a software that allows you to interweave text and R code to create HTML, PDF, and Microsoft Word documents

There are two ways to view a Quarto document, (1) as the “Source” file, or (2) as the “Visual” file. We will only use the Visual option in this class, as it allows you to interact with Quarto similar to how you interact with Word.

Formatting your Document

Similar to a Word Doc, there are a variety of ways you can spice up a Quarto document! Let’s explore a few.

Question 1: Using the formatting options, make a numbered list of your top three favorite animals.

Question 2: Using the formatting options, insert an image of your favorite animal.

Question 3: Now, change the “Formatting your Document” section name to the name of your favorite animal. Make sure your header is a level 1 – use the Header 1 formatting option!

R Code

You can differentiate the R code within a Quarto file from the body of the document, based on the gray boxes that start with an {r}.

Here is an example of an R code chunk:

Notice in the line after the {r} there are two lines that start with #| – this is the symbol that declares options for a code chunk. The #| label: allows us to specify a name for a code chunk, I typically choose a name that tells me what the code chunk does (e.g., load-packages, clean-data). The #| include: false option at the beginning of the code chunk controls how the code output looks in our final rendered document.

This code chunk has two things we want to pay attention to:

  1. The library(tidyverse) code loads in an R package called the “tidyverse”. This is code you will have in every lab assignment for this class!

  2. Code comments which are denoted by a # symbol. Code comments are a way for you (and me) to write what the code is doing, without R thinking what we are writing is code it should execute.

Rendering

When you click the Render button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Question 4: Do you see the above code chunk when you render the document? Why do you think this is the case?

Including Code Output

You can include code output in your rendered document:

glimpse(mpg)

Question 5: What do you think the above code does? What type of output does it give you?
Hint: You have saw this type of output on Tuesday!

Including Plots

You can also embed plots in the rendered document.

Here is an example of a plot.

Question 6: What do you think the echo: false option does in the above code chunk?

Question 7: What do you think the mapping = aes(y = manufacturer, x = hwy)) code does?

Question 8: What do you think the labs(x = "Highway Miles Per Gallon", y = "Car Manufacturer") code does?