Aesthetics must be either length 1 or the same as the data (21): y

Hi, I need to plot a graph with two lines. I tested the first line and it works perfectly but as soon as I try to trace the second line even separately this error message appears : Aesthetics must be either length 1 or the same as the data (21): y.
Here is the Dataset that I'm currently using and here is the code that I wrote : ggplot() + geom_point(data = Average_corruption_per_region, aes(x = Group.1, y = cpi_ti), color = "blue") + geom_point(data = Average_corruption_per_region, aes(x = Group.1, y = av_corr_LatinAmerica), color = "red").

This is my first post so feel free to ask me for more detail if I am not giving all the information.
Thank you in advance !

The link doesn't work, Can you turn this into a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

data.frame(
Group.1 = c(1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997),
av_corr_LatinAmerica = c("c(1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997)",
"c(NaN, NaN, NaN, NaN, NaN, 4.19333333333333, 3.53625, 3.63555555555556)"))
Here is the reprex for the column that is not working

That is not what I meant, we need enough data to reproduce your code, a single column is not enough, please read the guide in the link I gave you before and try to make a proper reproducible example.

Group.1 cpi_ti
1 1990 NaN
2 1991 NaN
3 1992 NaN
4 1993 NaN
5 1994 NaN
6 1995 9.175
7 1996 9.015
8 1997 9.045
9 1998 9.050
10 1999 9.050
av_corr_LatinAmerica
1 c(1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999)
2 c(NaN, NaN, NaN, NaN, NaN, 4.19333333333333, 3.53625, 3.63555555555556, 3.375, 3.4875)

Would this be the right one ?

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.