I have the following data:
head(MP_rates_dateformat)
Month repo revrepo bankrate CRR Callrate WPI GDP FED
1 2001-04-01 9.00 6.75 7 8.0 7.
Here is a solution based on the idea of melting/gathering the data, using fill
in ggplot
combined with position = "identity"
. Note that the order of the columns is important as the smallest value revrepo
should be plot after the first one repo
.
library("tidyr")
df_gather <- gather(select(MP_rates_dateformat, 1:3), variable, value, -Month)
library("ggplot2")
ggplot(data = df_gather, aes(x = Month)) +
geom_area(aes(y = value, fill = variable), position = "identity")
Finally Got it!
library("tidyr")
long_DF<- MP_rates_dateformat[,1:3] %>% gather(variable, value, -Month)
head(long_DF)
Month variable value
1 2001-04-01 repo 9.00
2 2001-05-01 repo 8.75
3 2001-06-01 repo 8.50
4 2001-07-01 repo 8.50
5 2001-08-01 repo 8.50
6 2001-09-01 repo 8.50
library("ggplot2")
ggplot(data = long_DF, aes(x = Month)) +
geom_area(aes(y = value, fill = variable), position = "identity") + labs(fill="") + xlab('\nYears') + ylab('LAF Rates (%)\n') + labs(title="Overlapping - Repo & Reverse Repo\n")