Untitled

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:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4

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

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
library(ggplot2)
library(dplyr)
library(nycflights23)

my_data<-data(flights)
head(flights)
# A tibble: 6 × 19
   year month   day dep_time sched_dep_time dep_delay arr_time sched_arr_time
  <int> <int> <int>    <int>          <int>     <dbl>    <int>          <int>
1  2023     1     1        1           2038       203      328              3
2  2023     1     1       18           2300        78      228            135
3  2023     1     1       31           2344        47      500            426
4  2023     1     1       33           2140       173      238           2352
5  2023     1     1       36           2048       228      223           2252
6  2023     1     1      503            500         3      808            815
# ℹ 11 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
#   tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
#   hour <dbl>, minute <dbl>, time_hour <dttm>
my_data <-flights |> mutate(Airport=ifelse(origin=="JFK","John F. Kennedy",ifelse(origin=="LGA","LaGuardia","Newark Liberty")))#changes name of airport to full name by using ifelse to check for abb.
ggplot(my_data,aes(x=Airport,y=distance,fill=Airport))+#my boxplot data 
  geom_boxplot()+
  ggtitle("Flight Distance by Departure Airport (NYC Flights, 2013)")+#title and caption for my graph
  xlab("Departure Airport")+
  ylab("Distance (miles)")

I made a box plot comparing the distance of flights leaving NYC in 2013 from its three departure airports JFK, LGA, and EWR. I replaced the three-letter airport abb. with full names, then filled in colors for each airport. Each box shows the middle 50% of that airport’s flights, the thick line is the median distance, and the dots are unusually long flights. The aspect I want to highlight is how different the spread of distances is across the airports. JFK has the tallest box, with its middle 50% of flights running from about 400 to 2,000 miles, which suggests it handles both short domestic trips and long-distance routes. LaGuardia has the lowest median, around 700 miles, and the shortest box, and its longest flights stay under about 2,500 miles. Newark’s median is similar to JFK’s, at roughly 900 miles, but its box is narrower. JFK and Newark also have outliers near 5,000 miles, likely flights to Hawaii, which LaGuardia has none of.