how to fix 'x' and 'y' lengths differ

plot(x=population, y= CO2, data = year15)
plot(x=carb, y=CO2, data = year15)
plot(x=gdppc, y=CO2, data = year15)

Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ

how do i fix this error?

What is the object year15? Can you post the output of

summary(year15)

summary(year15)
iso_code country year co2
Length:166 Length:166 Min. :2015 Min. : 0.121
Class :character Class :character 1st Qu.:2015 1st Qu.: 5.326
Mode :character Mode :character Median :2015 Median : 22.109
Mean :2015 Mean : 207.612
3rd Qu.:2015 3rd Qu.: 91.349
Max. :2015 Max. :9848.420
NA's :1
population gdp co2_per_gdp
Min. :7.118e+04 Min. :6.877e+08 Min. :0.0210
1st Qu.:4.111e+06 1st Qu.:2.963e+10 1st Qu.:0.1410
Median :1.047e+07 Median :9.335e+10 Median :0.2080
Mean :4.416e+07 Mean :6.367e+11 Mean :0.2487
3rd Qu.:3.081e+07 3rd Qu.:4.170e+11 3rd Qu.:0.3120
Max. :1.407e+09 Max. :1.690e+13 Max. :1.2020
NA's :1
gdppc carb
Min. : 691.2 Min. :0
1st Qu.: 3595.1 1st Qu.:0
Median : 11656.7 Median :0
Mean : 18007.8 Mean :0
3rd Qu.: 24063.6 3rd Qu.:0
Max. :146153.0 Max. :0
NA's :1

I notice that there is no column named CO2 in year15. There is one named co2. Try changing your plot commands to commands like

plot(x=population, y= co2, data = year15)

If that does not fix the problem, please run

dput(head(year15, 30))

and post the output here. Put a line with three back ticks just before and after the pasted output, like this
```
Pasted output goes here
```

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.