Hello All,
I am running below code :
#----install package-----
installed.packages()
install.packages("nycflights13")
library(nycflights13)
nycflights13::flights
#----scatter plot-----
attach(nycflights13::flights)
plot(arr_delay[carrier = "UA"], dep_delay[carrier == "UA"])
points(arr_delay[carrier == "AA"], dep_delay[carrier == "AA"], pch = 4)
But i am getting below error from plot statement:
> plot(arr_delay[carrier = "UA"], dep_delay[carrier == "UA"])
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
> points(arr_delay[carrier == "AA"], dep_delay[carrier == "AA"], pch = 4)
On the other hand below plot statement is running just fine without carrier filter condition:
plot(arr_delay, dep_delay, main = "Arrival vs Departure Delay",
xlab = "Arrival Delay", ylab = "Departure Delay", pch='p')
Can you point out what am i doing wrong here.
Thank you.