NY Flights hw

#install.packages("nycflights23")
library(nycflights23)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.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
flights_nona <- flights |>
  filter(
    !is.na(distance),
      !is.na(arr_delay),
      !is.na(dep_delay)
    )
by_dest <- flights_nona |>
 group_by(dest)|>
  summarize(
    count=n(),
    avg_distance=mean (distance, na.rm=TRUE),
    avg_arr_delay=mean(arr_delay,na.rm=TRUE)
    )
by_dest_matrix <- data.matrix(by_dest[,-1])
row.names(by_dest_matrix) <- by_dest$dest
library(viridis)
Loading required package: viridisLite
by_dest_heatmap <- heatmap(by_dest_matrix,
                           Rowv=NA,
                           Colv=NA,
                           col = viridis(150),
                           cexCol = .7, # shrink x-axis label size
                           scale="column",
                           xlab = "",
                           ylab = "",
                           main = "")

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:

You can add options to executable code like this

The echo: false option disables the printing of code (only output is displayed).