@ Nicolas Rosewick , thank you very much, this worked.
I have another question, I have 300 genes and grouped based on a particular ID as given below. How do I gather 300 genes using the dplyr library as in the previous scenario there were only 4 genes which was easy to input. Also, In addition, how do I extract only the genes belonging to the particular ID (ID column) and plot the same. For instance, X-axis are the Timepoints and Y-axis is the value, which match only to the ID A1.2, then A1.6 and so on. Is it possible to loop the same? Thank you.
Timepoints Gene Value ID
1 Gene A -0.404452 A1.2
2 Gene A -0.276019 A1.2
1 Gene B -0.47392 A1.2
2 Gene B -0.653023 A1.2
1 Gene C -1.64114 A1.2
2 Gene C -2.04769 A1.2
1 Gene D -0.865624 A1.2
2 Gene D -2.16485 A1.2
1 Gene AA -0.0588112 A1.6
2 Gene AA -3.75268 A1.6
1 Gene BB -3.75268 A1.6
2 Gene BB -4.61661 A1.6
1 Gene CC -2.39765 A1.6
2 Gene CC -4.46908 A1.6
1 Gene DD -3.97157 A1.6
2 Gene DD -3.75419 A1.6
1 - - A1.8
2 - - A1.8
1 Gene n - A2.0
2 Gene n - A2.0

Explained in this post. Kindly refer.
@Chirag Parsania, thank you for the suggestions. I could get the expected plots.
I have two questions,
This is plotted just with the few IDs (last column), I have more than hundred IDs and saving the pdf looks fuzzy. Is there a way to include all the plots corresponding to the ID by setting margins in the pdf report.
Include the gene names inside each ID box, as separate legend occupies more space and not very interpretive in case of large data.
dput(head(final))
In the plot above you showed, you should make
valuecolumn tonumericrathercharacter. It will make your y-axis visually look much better than current. Also, if you have more than 100 genes to show each with name of each in legend, probably line plot is not a good idea. Better you use heatmap.@Chirag Parsania,
Thank you for the observation. Yes, the y-axis now looks better.