```{r}
#| label: fig-mtcars-plot
#| fig-cap: "Fuel efficiency of cars vs. their displacement."
ggplot(mtcars, aes(x = disp, y = mpg)) +
geom_point()
```
Lab - Project draft
Learning goals
In this lab, you will…
- Review your project proposal feedback and address it
- Finalize your data selection and analysis plan
- Work on your project draft
Getting started
- Go to RStudio and open the RStudio project called
project
. You can do this by navigating to it from the top right corner of your RStudio window. - Pull to bring in any changes your teammates may have made to the project.
- Go to the Build tab and click Render website.
- Make sure it compiles without errors. View your project website in your Viewer tab.
Tasks
Proposal feedback review
- As a team, review all feedback left as issues in your GitHub repo.
- Either close the issues on GitHub (by clicking on the Close Issue button) or address them with commits to your project like you learned last week.
- Make decision about which dataset you will use for your project and going forward write up your analysis in
report.qmd
.
Project draft
- Review https://sta199-f22-1.github.io/project-description.html#draft for requirements for the project draft.
- Start working on your draft! Make good use of the time with your TA during lab.
- Once you complete your draft but before you finalize it:
In
report.qmd
setecho: false
in the YAML of your document. Read through your draft completely and make sure everything makes sense without the code visible, and make any edits as needed. Then, setecho: true
again before submitting. (For your draft we want to see your code so we can provide feedback on it. For your final report we will ask you to hide it again.)Update your
index.qmd
:Update the
title
field with your team name.Add your abstract.
Update your About page (
about.qmd
) with information on your team.
Quarto options
Theming
You can see your deployed project website at the URL listed in your project repo.
- You can pick a theme from https://quarto.org/docs/output-formats/html-themes.html.
- You can update the theme of your project by changing the
theme
field in the_quarto.yml
file. - Render the website from the Build tab and commit and push your changes.
Footnotes
To add a footnote, make sure you’re in the Visual editor mode in RStudio and click on Insert > Footnote.1 One you add your footnote, click outside of the footnote area, anywhere else in your document, to go back to editing your document.
Cross references
You can add cross references to your figures and tables so that you can refer to them like “Figure 1 shows that …” or “As seen in Table 1, …” instead of “the figure below” or “the table below”. To do this, you need to label the code chunks for those figures and tables in a special way (with fig-
and tbl-
suffixes, respectively) and add captions to them.
Figures
For example, Figure 1 shows a positive and moderately strong relationship between fuel efficiency of cars (measured as miles/gallon) and their displacement.
What you’re not seeing in the text above is that we didn’t type Figure 1
in the text, but instead referenced this figure with @fig-mtcars-plot
:
For example, @fig-mtcars-plot shows a positive and moderately strong relationship between fuel efficiency of cars (measured as miles/gallon) and their displacement.
Tables
And Table 1 shows the output of the linear regression for predicting fuel efficiency from displacement.
Note that we piped the result of the tidy()
function (which outputs a tibble) into the kable()
function from the knitr package to turn it into a table. Quarto needs this last step to know that this code chunk produces a table that can be formatted and cross referenced as such.
```{r}
#| label: tbl-mpg-disp
#| tbl-cap: "Linear regression model for predicting fuel efficiency from displacement."
linear_reg() |>
fit(mpg ~ disp, data = mtcars) |>
tidy() |>
::kable()
knitr```
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | 29.5998548 | 1.2297195 | 24.070411 | 0 |
disp | -0.0412151 | 0.0047118 | -8.747151 | 0 |
Once again, what you’re not seeing in the text above is that we didn’t type Table 1
in the text, but instead referenced this table with @tbl-mpg-disp
.
And @tbl-mpg-disp shows the output of the linear regression for predicting fuel efficiency from displacement.
Footnotes
Here is a footnote!↩︎