I have a dataset like this:
T A B C D
0 1 2 2 4
1 1 4 1 5
2 1 7 2 4
3 2 9 4 0
4 2 0 3 0
5 2 3 7 1
6 1 7 3 5
7 1 7 3 5
8 3 1 6 0
9 3 2 3 9
10 1 2 2 4
11 1 4 1 5
12 1 7 2 4
13 2 9 4 0
14 2 0 3 0
15 2 3 7 1
I want to plot the data in R using ggplot as time series. Here T is the time (x axis). There will be 3 lines for the column B, C and D. I need to highlight the whole plot depending on the values in column A.
For example, if value in A is 1 I don't need to do anything. if value in A is 2 I need to highlight the portion (ex. Time 5-7 and Time 15-16) by a yellow rectangle. if value in A is 3 I need to highlight the portion (ex. Time 10-11) by a blue rectangle.
So the plot should look like a time series plot with several transparent rectangles on it, which will highlight the areas where A has a specific value. I need to add those colors as legend also.