More Quarto

Published

February 11, 2025

You will be adding to your assignment-01.qmd 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:


Add a Code Chunk to Create a Figure

  1. Open the Assignment 1 R project (assignment-01.Rproj) you created from last class. Then open the QMD document you started last class.

  2. In the “Question 7” section of your document, add a code chunk. In this chunk, write the syntax to create a scatterplot of new knowledge scores (y-axis) versus news exposure (x-axis).

  3. Add a label, appropriate caption, and alternative text to your code chunk using code chunk options.

  4. Adjust the aspect ratio of the plot using #| fig-width: and #| fig-height: in the code chunk so that it looks good.

  5. Change the values of the chunk options #| out-width: and/or #| out-height: to change the size of the rendered plot from the default values.


Add an Inline Equation and an Inline Code Chunk

  1. In the “Question 4” section of your document, Write the following sentence: “The Root Mean Square Error (RMSE; \(\hat\sigma_{\epsilon}\)) is \(x\).”

  2. Prior to that sentence, add a regular code chunk that assigns the glance() output for Model 1 into an object. Hide the syntax for this code chunk.

  3. Use an inline code chunk to replace \(x\) in that sentence with the value for the RMSE from the fitted equation by extracting the sigma value from the object that contains the glance() output.


Add a Multiline Equation

  1. In the “Question 6” section of your document, add a display equation. In this equation, compute \(R^2\) using the sum-of-squares values from the ANOVA decomposition you computed in Question 5. You can use \frac{}{} to create a fraction—inside the first curly braces put what you want in the numerator, and in the second set of curly braces put what you want in the denominator.


Cross-Reference a Figure

  1. In the “Question 10” section of your document, add a sentence that cross-references the figure you created in for Question 1 in the assignment. The rendered sentence should produce a link that, when clicked, brings you to the plot.


Citations and Bibliography

  1. Download the PDF file of the Fox textbook and add it to your Zotero library. (Or to whichever reference/bibliography software you are using.)

  2. Also download a PDF of a journal article—you probably already have one :)—and add it to your Zotero library.

  3. Be sure to update the metadata for both references after you import them into Zotero.

  4. Use Zotero to export a BIB file that includes the Fox textbook and your journal article. Place that BIB file in the assets directory of your project.

  5. Download one of the APA CSL files from the Zotero Style Repository. Place that CSL file in the assets directory of your project.

  6. Update the YAML of your QMD document to include the bibliography: key. For its value, inside of quotation marks, provide the path and filename of your BIB file relative to your QMD file.

  7. Update the YAML of your QMD document to include the csl: key. For its value, inside of quotation marks, provide the path and filename of your CSL file relative to your QMD file.

  8. In the “Question 9” section of your document, write a sentence that includes citations to both references. You can choose the topic of the sentence and how the two references are used in the citation.

  9. Add a Level-1 header called “References” at the end of your QMD file.

  10. After you do all of this and render the file, check your sentence to see that it looks correct and that the references have rendered properly.


Add a Table

You may want to read through Creating Tables with gt in the Advanced Modeling book.

  1. In the “setup” code chunk, load the {gt} library. (If you haven’t yet installed it, you will need to do that first.)

  2. In the “Question 8” section of your document, add a code chunk. In this chunk, write the syntax included in Question 8 from Assignment 1 to compute the summary statistics.

  3. Use the functions from the {gt} package to re-create Table 1 from Slide 34. Do this in steps, rendering after you add each line of gt syntax.

  • Pipe tab_01 into the gt() function.
  • Pipe that into the function to re-name the variables.
  • Pipe that output into the function to round numerical output to the same number of decimal places as in the slides.
  • Pipe that output into the function to add a the footnotes.
  1. Add the code chunk option #| label: and #| tab-cap: to label the table and add a caption.