You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error in xy.coords(x, y) : 'x' and 'y' lengths differ
...means that you've specified a different number of values for x coordinates and y coordinates.
When we create a scatter plot with points(), each data point has a pair of values:
The x coordinate
The y coordinate
When x and y are use together, they can be plotted along an x- and y-axis, or a "Cartesian plane".
When you supply multiple coordinate values for x, you must supply the same number of coordinate values for y.
plot(x = 1:10,
y = 11:20)
However, if you only provide, e.g., 5 coordinate values for x and 6 coordinate values for y, it results in an error because there is a sixth y coordinate value with no matching or paired x coordinate value.
In your call to points(), your y = argument is specified as ave.so and your x = argument specifies year, so this means that you either have more values for average league strikeouts than total years, or more total years than values for average league strikeouts, and they do not make equal x-y coordinate pairs.
Try this to determine the number of values in each object:
length(year)
length(ave.so)
It's likely that earlier in your script you did something to change the values in these objects so that they are no longer equal, like filtering or subsetting. I cannot tell you more without seeing those parts of the script.
when i am trying to code the first chunk as plot.new()
plot.window(xlim = c(1900, 2012),
ylim = c(ave.so.min,
ave.so.max))
points(x = year,
y = ave.so,
col = "gray85",
pch = 16,
cex = 0.75)
, I find this msg "error in xy.coords(x, y) : 'x' and 'y' lengths differ"
I am not sure what is wrong ? Can you help please?
The text was updated successfully, but these errors were encountered: