# Simulated data for illustration purposes
years <- 2000:2020
births <- sample(100000:120000, length(years), replace = TRUE)
deaths <- sample(60000:80000, length(years), replace = TRUE)
nj_births_deaths <- data.frame(
year = years,
births = births,
deaths = deaths
)Quarto
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:
# Calculate the difference between births and deaths
nj_births_deaths <- nj_births_deaths %>%
mutate(difference = births - deaths)
# Plot the data
births_deaths_plot <- ggplot(nj_births_deaths, aes(x = year)) +
geom_line(aes(y = births, color = "Births")) +
geom_line(aes(y = deaths, color = "Deaths")) +
geom_line(aes(y = difference, color = "Difference (Births - Deaths)")) +
labs(title = "Births and Deaths in New Jersey (2000-2020)",
x = "Year",
y = "Count",
color = "Legend") +
theme_minimal()
print(births_deaths_plot)