22  Test

22.1 Standards

22.1.1 For displaying figures:

22.1.2 For displaying code and even variable names

demo <- function(x) variable_2

22.1.3 For sizing graphs and code-generated plots

  • You can specify out-height or out-width as either pixels, inches, or percentages
  • You can specify both using different units
  • If you specify only one, the other should default to “auto” which keeps the figured scaled as in the original
plot(pressure)

22.1.4 For code annotation

library(tidyverse)
1
make a df
2
glimpse a df
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.0     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
1d <- tibble (x = 1:5) |>
2  glimpse()
Rows: 5
Columns: 1
$ x <int> 1, 2, 3, 4, 5

22.1.5 For displaying color (like red questions)

this sentence is in red

This is an alternative method but more complex: I love R.

red yellow green blue

yellow background for better contrast

22.1.6 Callouts for questions

HTML:

Here’s the answer! This can be as long as you want.

RevealJS does not yet have callout collapse implemented. A workaround is to use code folding:

If the DGP for y is a cubic function of x, what do we know about the expected bias for our three candidate model configurations in this example?
Show Answer
The simple linear model will underfit the true DGP and therefore it will be biased b/c 
it can only represent y as a linear function of x.  

The two polynomial models will be generally unbiased b/c they have x represented 
with 20th order polynomials.  

LASSO will be slightly biased due to regularization but more on that in a later unit

22.1.7 Conditional Content

Use divs to specify content to only appear in certain formats:

Will only appear in HTML.