# Most basic bubble plot
Currency <- c("PKR","INR","BDT")
data <- data %>% filter(Currency_Code %in% Currency)
data[is.na(data)] <- 0
Remove <- c("198","199","200","201","202","203","204","130","131","132","133","134","135","136","62","63","64","65","66","67","68")
All <- c(1:204)
Keep <- setdiff(All,Remove)
data_long <- gather(data, Year,Exchange_Rate, X1953:X2020)
data_long <- data_long %>% arrange(Currency_Code, desc(Year))
data_long <- data_long[Keep,]
data_long$Year <- substr(data_long$Year,2,5)
colnames(data_long) <- c("Currency","Year","Exchange Rate")
data_long$Year <- as.Date(as.character(data_long$Year), format = "%Y")
data_long$Currency <- as.character(data_long$Currency)
data_long$Currency <- as.factor(data_long$Currency)
datatable(data_long, filter = "top",
options = list(pageLength = 5))
as.character(unique(data_long$Currency)) # India, Bangladesh, Pakistan Currency performance against USD
## [1] "BDT" "INR" "PKR"
as.character(max(data_long$Year)) #latest data point 2020
## [1] "2020-06-24"
as.character(min(data_long$Year)) # earliest datapoint 1960
## [1] "1960-06-24"
PKR <- data_long %>% filter(Currency == "PKR")
max(PKR$`Exchange Rate`) # highest PKR exchange rate
## [1] 158.4874
min(PKR$`Exchange Rate`) # lowest PKR exchange rate
## [1] 4.7619
INR <- data_long %>% filter(Currency == "INR")
max(INR$`Exchange Rate`) # highest INR exchange rate
## [1] 73.89841
min(INR$`Exchange Rate`) # lowest INR exchange rate
## [1] 4.7619
BDT <- data_long %>% filter(Currency == "BDT")
max(BDT$`Exchange Rate`) # highest BDT exchange rate
## [1] 84.90307
min(BDT$`Exchange Rate`) # lowest BDT exchange rate
## [1] 0
ap <- ggplot(data_long, aes(x=Year, y=`Exchange Rate`, color = Currency)) +
geom_line() +
xlab("")+
geom_point()+
scale_x_date(date_breaks = "3 year",date_labels = "%Y")+
ylim(0, 160) +
scale_y_continuous(breaks=c(0,25,50,75,100,125,150,175)) +
theme_bw()+
ggtitle(label = "Currency versus USD Exchange Rate",
subtitle = "1960 - 2020")
## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
ggplotly(ap)
Figure 1: Currency Exchange Chart (Only years in the dates are relevant )