I have a data frame, dratiodf
:
Date D10 D21 D63 D126 D252
2019-09-23 0.1557585 0.3977892 0.8583822 0.7153107 0.7517688
2019-09-24 0.1513844 0.2142586 0.7501128 0.6736790 0.7275896
2019-09-25 0.5314460 0.4254800 0.8604258 0.6612713 0.7469207
2019-09-26 0.5135381 0.4250006 0.9424716 0.7008503 0.7661933
2019-09-27 0.4816461 0.2371428 0.7969672 0.6351504 0.7307106
2019-09-30 0.6414031 0.3407633 0.8207621 0.6854996 0.7346074
What I would like to do is melt the columns together to have a data frame that looks like this:
Date: Type: Value:
2019-09-23 D10 0.1557585
2019-09-23 D21 0.3977892
2019-09-23 D63 0.8583822
2019-09-23 D126 0.7153107
2019-09-23 D252 0.7517688
2019-09-34 D10 0.1513844
2019-09-34 D21 0.2142586
I want this so that I can facet the eventual plot by Type, like this:
ggplot(dratiodf, aes(x=Date, y=Value))+
geom_line()+
facet_wrap(.~type)+
theme_wsj()
I've tried using the melt function, but I just can't wrap my head around how to use it.
Also, can you spot any problem with my graph code, something that won't work?