I have OTC Notional outstanding amount, here is the data
My objective is to:
- Plot Date against Notional,
- Plot Date against Percentage, where percentage is calculated as a percentage change in notional.
However, I want to calculate percentage in r instead of excel.
- Plot Date against (GMV as percentage of Notional) , calculate GMV as percentage of notional in r.
I want to plot this in one graph with two independent y-axes
However I only manage to do number 1. (Plot Date against Notional) here is the code
library("ggplot2") library("scales") OTCData <- read.csv("~/r programs/Research/DerivativeMeasure.csv") OTCData <- mutate(OTCData, Date = as.Date(OTCData$Date, "%m/%d/%Y")) ggplot(data = OTCData, aes(x = OTCData$Date, y = OTCData$Notional)) + geom_boxplot()+ geom_line(aes(x = Date, y = Notional), color = "#09557f", alpha = 0.6, size = 0.6, group =1) + labs(x = "Date", y = "Notional Amount") + ggtitle("Notional Outstanding Amount of OTC derivatives")+ theme(panel.background = element_rect(fill="white", colour="white", size=0.5, linetype="solid", color="grey"), plot.title = element_text(hjust = 0.5), panel.grid.minor = element_line(size = (0.2), colour="grey"), axis.text.x=element_text(angle=60, hjust=1))
Now how can I do the 2 and 3 ?