‘x’ and ‘y’ lengths differ ERROR when plotting

From the code you provided, Vehic_vol is not a column of VehicleData. If you enter in

VehicleData$Vehic_vol

it returns

NULL

Note that NULL and VehicleData$CITY_MPG have different lengths (use length() to verify that).

Try this instead

plot (Vehic_vol, VehicleData$CITY_MPG)

or

VehicleData$Vehic_vol <- (VehicleData$Psgr_Vol + VehicleData$Lugg_Vol)
plot (VehicleData$Vehic_vol, VehicleData$CITY_MPG)

Leave a Comment