line graph/time series graph

i wanted to plot a time-graph of the GDP of two countries.

the code i used was

dataframa %>% ggplot(aes(x=Years, y=GDP, colour=Country Name)) geom_line()

however, the graph i am getting when i use this code is

which is not correct.

i cannot tell what my mistake is since every source i refer to has either this code or some variation of this code. i have tried two variations which gave no results or the same result.

Try setting group = Country Name in the aes function

 ggplot(aes(x=Years, y=GDP, group = `Country Name`, colour= `Country Name`))

If that does not fix the problem, please post your data by posting the output of


This topic was automatically closed 7 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.