Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org .
Running Code
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
library (fredr)
library (tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0 ✔ purrr 0.3.4
✔ tibble 3.1.8 ✔ dplyr 1.0.9
✔ tidyr 1.2.0 ✔ stringr 1.4.1
✔ readr 2.1.2 ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
library (dplyr)
library (tsibble)
Attaching package: 'tsibble'
The following objects are masked from 'package:base':
intersect, setdiff, union
fredr_set_key ("70919fe213e30e6afca54803aa407c43" )
unrate <- fredr (
series_id = "UNRATENSA" ,
observation_start = as.Date ("2010-01-01" ),
observation_end = as.Date ("2018-12-01" )
) %>%
select (date, value) %>%
mutate (value = value/ 100 ) %>%
mutate (date = yearmonth (date)) %>%
as_tsibble (index = date)
unrate_test <- fredr (
series_id = "UNRATENSA" ,
observation_start = as.Date ("2019-01-01" ),
observation_end = as.Date ("2019-12-01" )
) %>%
select (date, value) %>%
mutate (value = value/ 100 ) %>%
mutate (date = yearmonth (date)) %>%
as_tsibble (index = date)
cons_sent <- fredr (
series_id = "UMCSENT" ,
observation_start = as.Date ("2010-01-01" ),
observation_end = as.Date ("2018-12-01" )
) %>%
select (date, value) %>%
mutate (date = yearmonth (date)) %>%
as_tsibble ()
Using `date` as index variable.
cons_sent_test <- fredr (
series_id = "UMCSENT" ,
observation_start = as.Date ("2019-01-01" ),
observation_end = as.Date ("2019-12-01" )
) %>%
select (date, value) %>%
mutate (date = yearmonth (date)) %>%
as_tsibble ()
Using `date` as index variable.
cons_sent_plot <- cons_sent %>%
ggplot () +
geom_line (aes (date, value)) +
theme_bw () +
xlab ("Date" ) +
ylab ("Consumer Sentiment" )
unrate_plot <- unrate %>%
ggplot () +
geom_line (aes (date, value)) +
theme_bw () +
xlab ("Date" ) +
scale_y_continuous (
name = "Unemployment Rate" ,
labels = scales:: percent
)
You can add options to executable code like this
The echo: false option disables the printing of code (only output is displayed).