rate_for_balance <- read.csv("rate_for_balance.csv",
                          stringsAsFactors = F,
                          fileEncoding = "euc-kr",
                          encoding = "utf-8")
interest_rate <- rate_for_balance
View(interest_rate)

interest_rate$X16.1Q <- (interest_rate$X16.Feb + interest_rate$X16.Mar) / 2
interest_rate$X16.2Q <- (interest_rate$X16.Apr + interest_rate$X16.May + interest_rate$X16.Jun) / 3
interest_rate$X16.3Q <- (interest_rate$X16.Jul + interest_rate$X16.Aug + interest_rate$X16.Sep) / 3
interest_rate$X16.4Q <- (interest_rate$X16.Oct + interest_rate$X16.Nov + interest_rate$X16.Dec) / 3
interest_rate$X17.1Q <- (interest_rate$X17.Jan + interest_rate$X17.Feb + interest_rate$X17.Mar) / 3
interest_rate$X17.2Q <- (interest_rate$X17.Apr + interest_rate$X17.May + interest_rate$X17.Jun) / 3 
interest_rate$X17.3Q <- (interest_rate$X17.Jul + interest_rate$X17.Aug + interest_rate$X17.Sep) / 3
interest_rate$X17.4Q <- (interest_rate$X17.Oct + interest_rate$X17.Nov + interest_rate$X17.Dec) / 3
interest_rate$X18.1Q <- (interest_rate$X18.Jan + interest_rate$X18.Feb + interest_rate$X18.Mar) / 3
interest_rate$X18.2Q <- (interest_rate$X18.Apr + interest_rate$X18.May + interest_rate$X18.Jun) / 3
interest_rate$X18.3Q <- (interest_rate$X18.Jul + interest_rate$X18.Aug + interest_rate$X18.Sep) / 3
interest_rate$X18.4Q <- (interest_rate$X18.Oct + interest_rate$X18.Nov + interest_rate$X18.Dec) / 3 
interest_rate$X19.1Q <- (interest_rate$X19.Jan + interest_rate$X19.Feb) / 2
View(interest_rate)

interest_rate <- interest_rate[, -c(1:38)]
View(interest_rate)

colnames(interest_rate) <- NULL
rownames(interest_rate) <- NULL
View(interest_rate)

interest_rate <- t(interest_rate)
interest_rate <- data.frame(interest_rate)
View(interest_rate)

rownames(interest_rate) <- timing
View(interest_rate)

interest_rate <- cbind(timing, interest_rate)
View(interest_rate)

library(reshape2)
rate <- melt(id=1, data=interest_rate)
head(rate)
colnames(rate) <- c("timing", "default", "rate")
head(rate)

library(ggplot2)
ggplot(data=rate, aes(x=timing, y=rate, group=default)) + geom_line()
