I have the following Panel Data
year region ka_avg kao_avg
1995 East Asia & Pacific 0.534 0.508
1995 Europe & Central Asia 0.553 0.579
1995 Latin America & Caribbean 0.252 0.232
1995 Middle East & North Africa 0.382 0.348
1995 North America 0.0833 0.0556
1995 South Asia 0.799 0.865
1995 Sub-Saharan Africa 0.667 0.748
1995 W Europe 0.114 0.117
1996 East Asia & Pacific 0.465 0.416
1996 Europe & Central Asia 0.561 0.630
I need a graph like the following for ka_avg and another for kao_avg :
where the y-axis is each of the variables mentioned above and the x-axis has the variable year . The labels to each line correspond to region
What I have done is the following
ggplot(data = dataset, aes(x = year, y = ka_avg, color = region)) +
geom_line()
I would like to give it a look similar to the first
I would do it using twice
geom_line()
.The syntax would be the following:
In the first
geom_line()
I place all the lines and assign them the light blue color. Immediately after I add onegeom_line()
that only considers the series that interest me, I do this with a filterdata = df %>% filter(grepl("A|C|D|F",var2))
To make it similar to the one you show in the image, you would have to make some changes to
theme()
. But the general structure would be like that.