i am not able to get the legend in the ggplot. I am sharing the codes and sample data.
Thanks in advance
ggplot(data_plot, aes(x = year, y = cr5))+
geom_line(lty=1,lwd=1)+
geom_line(aes(y = cr10), lty = 4,lwd=1) +
geom_line(aes(y = hhi), lty = 5,lwd=1) +
ylim(0, 1)+
labs(title = "Concentration and Herfindahl-Hirschman Index (HHI) during 1998-2022.",
x = "", y = "") +
legend("right", legend = c("CR5","CR10","HHI"), lty = c(1,3,5))
data
year cr5 cr10 hhi
1998 0.442865985 0.602359898 0.068173993
1999 0.442112595 0.59911706 0.070629232
2000 0.428284123 0.58547981 0.069995583
2001 0.427560433 0.57782029 0.073030846
2002 0.420737851 0.589867065 0.069163224
2003 0.41490982 0.579500901 0.066778344
2004 0.405780603 0.562992614 0.062079985
2005 0.409185991 0.56774689 0.061313117
2006 0.409889632 0.567925388 0.057598804
2007 0.400818962 0.555345738 0.05447507
2008 0.391401773 0.552378214 0.054399859
2009 0.390753752 0.559887514 0.057698474
2010 0.378917568 0.562713007 0.054927221
2011 0.378429764 0.565822881 0.053595005
2012 0.374710642 0.561201979 0.050980428
2013 0.374360531 0.5612071 0.051485629
2014 0.380564753 0.567547842 0.05196086
2015 0.386667899 0.581758511 0.054680071
2016 0.392207847 0.581341906 0.056336758
2017 0.424217031 0.618156689 0.065374265
2018 0.451438767 0.632555218 0.075765853
2019 0.458840157 0.64161298 0.076725092
2020 0.518466992 0.706075594 0.087544266
2021 0.512412498 0.7482065 0.089257398
2022 0.516847614 0.750248724 0.089732408