pew = read_csv("data/pew.csv")Hello World: Quarto
You will be creating your first (or second? third?) Quarto document. Each question will ask you to add something to your Quarto document. As you complete these tasks, you will not only be learning about a tool that is useful for reproducibile analytic work, but also beginning Assignment 1. As you work on this, you might want to reference different resources:
- If you are using the
Sourceeditor, check out the Markdown Basics page. This will include the Markdown syntax for basic things like creating headers, lists, adding links, etc. - R Script for the analysis presented in the slide deck
- Modeling textbook from EPSY 8251
- Assignment 1
Creating a Quarto Document
Open the Assignment 1 R project (
assignment-01.Rproj) you created from last class.Create a new Quarto document called
assignment-01.qmdand save this in your root directory. The tree for your project should now look like this:
assignment-01
├── README
├── assets
├── assignment-01.qmd
├── assignment-01.Rproj
├── data
│ └── pew.csv
├── figs
└── scripts
Updating the YAML
In the
assignment-01.qmdfile, update the title key to “Assignment 1”.Also add a subtitle (“Introduction to Quarto”), author, and date key to the YAML.
Adding Headings and Text
Add three Level-1 headings to your document: “Model 1”, “Figures and Tables”, and “Miscellaneous”. (Remember, headings need to have a blank line above and below them!)
Below the “Model 1” heading add six different Level-2 headings: “Question 1”, “Question 2”, “Question 3”, “Question 4”, “Question 5”, and “Question 6”. Below the “Figures and Tables” heading, add two Level-2 headings called “Question 7” and “Question 8”. Finally, below the “Miscellaneous” header add two Level-2 headers: “Question 9” and “Question 10”.
Separate each of the headings by adding some random text after each of them. Within some of the text, make some words italics and some words bold.
Add a Code Chunk to Load Libraries and Import Data
Immediately after the YAML (after the three dashes and before your first header), skip a line and create a new R chunk. (This should be before any of the headings you created previously.) In that chunk load the
{broom}and{tidyverse}libraries. Don’t forget to add a comment.In the same R chunk, import the
pew.csvdata into an object calledpew(see below). This has to be done after you load the libraries. To import the data (which you put in thedatadirectory of your project last class) use the following syntax:
- Give this chunk a label of
setup. Also be sure that the syntax in this chunk is not printed to your rendered document and that there are no warnings or messages printed.
Add a Code Chunk to Fit a Regression Model
Under the “Question 1” heading add a code chunk to fit the
lm()that regresses news knowledge on news exposure. Be sure to give this chunk a good label.In the same chunk, use
tidy()to obtain the coefficient-level output. Assign this output into an object calledlm1coefand print the results oflm1coef.
Unordered (Bulleted) List
- Under the “Question 2” heading, use a bulleted list to interpret the intercept and slope from the regression output. Use one bullet to interpret the intercept, and another to interpret the slope.
Add an Equation
- Under the “Question 3” heading, use a display equation to write the fitted equation for the model you fitted that regressed news knowledge on news exposure. Be sure to use the variable names and include subscripts. Also be sure the variable names are written in normal (non-italicized) font.
Add a Code Chunk to Output an ANOVA Decomposition
Under the “Question 5” heading add a code chunk to output the ANOVA decomposition for Model 1 using the
anova()function. Be sure to give this chunk a good label.Use code chunk options to hide the syntax and only print the results from
anova()in the rendered document.