Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Group5Labbonus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dhanush Kumar Reddy Narayana Reddy
Group5Labbonus
Commits
7bf920ce
Commit
7bf920ce
authored
4 months ago
by
Manu Jain
Browse files
Options
Downloads
Patches
Plain Diff
created visualize_airport_delay_dplyr file
parent
a2f0aae4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/visualize_airport_delay_dplyr.R
+28
-0
28 additions, 0 deletions
R/visualize_airport_delay_dplyr.R
with
28 additions
and
0 deletions
R/visualize_airport_delay_dplyr.R
0 → 100644
+
28
−
0
View file @
7bf920ce
install.packages
(
c
(
"nycflights13"
,
"dplyr"
,
"ggplot2"
))
library
(
nycflights13
)
library
(
dplyr
)
library
(
ggplot2
)
visualize_airport_delays
<-
function
()
{
# Join flights and airports datasets to include latitude and longitude
airport_delays
<-
flights
%>%
filter
(
!
is.na
(
dep_delay
))
%>%
# Exclude rows where departure delay is NA
group_by
(
origin
)
%>%
# Group by airport
summarize
(
mean_delay
=
mean
(
dep_delay
,
na.rm
=
TRUE
))
%>%
left_join
(
airports
,
by
=
c
(
"origin"
=
"faa"
))
# Join with airports for lat/lon data
# Create the ggplot2 plot
ggplot
(
airport_delays
,
aes
(
x
=
lon
,
y
=
lat
))
+
geom_point
(
aes
(
size
=
mean_delay
,
color
=
mean_delay
),
alpha
=
0.9
)
+
scale_color_gradient
(
low
=
"blue"
,
high
=
"red"
)
+
labs
(
title
=
"Mean Flight Delay by Airport"
,
x
=
"Longitude"
,
y
=
"Latitude"
,
size
=
"Mean Delay (min)"
,
color
=
"Mean Delay (min)"
)
+
theme_minimal
()
}
visualize_airport_delays
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment