Sys.setlocale(category = "LC_ALL", locale = "C") library("zoo") library("quantmod") # read norwegian exchange rates NOK_USD <- getSymbols("DEXNOUS", src="FRED", auto.assign=FALSE, ) head(NOK_USD) summary(NOK_USD) png("NOK_USD_from_1971.png",width=800,height=400) plot(NOK_USD) dev.off() # get japanese exchange rate JPY_USD <- getSymbols("DEXJPUS", src="FRED", auto.assign=FALSE, ) # remove missing observations NOK_USD <- na.omit(NOK_USD) names(NOK_USD) <- "NOK_USD" JPY_USD <- na.omit(JPY_USD) names(JPY_USD) <- "JPY_USD" annual_NOK_USD <- NOK_USD[endpoints(NOK_USD,on="year"),] head(annual_NOK_USD) annual_JPY_USD <- JPY_USD[endpoints(JPY_USD,on="year"),] ex <- merge(annual_NOK_USD,annual_JPY_USD) head(ex) monthly_NOK_USD <- NOK_USD[endpoints(NOK_USD,on="month"),] head(monthly_NOK_USD) index(monthly_NOK_USD) <- as.yearmon(index(monthly_NOK_USD)) head(monthly_NOK_USD) monthly_JPY_USD <- JPY_USD[endpoints(JPY_USD,on="month"),] head(monthly_JPY_USD) index(monthly_JPY_USD) <- as.yearmon(index(monthly_JPY_USD)) head(monthly_JPY_USD) ex <- merge(monthly_NOK_USD,monthly_JPY_USD) head(ex) summary(ex) quarterly_NOK_USD <- NOK_USD[endpoints(NOK_USD,on="quarter"),] head(quarterly_NOK_USD) index(quarterly_NOK_USD) <- as.yearqtr(index(quarterly_NOK_USD)) head(quarterly_NOK_USD) quarterly_JPY_USD <- JPY_USD[endpoints(JPY_USD,on="quarter"),] head(quarterly_JPY_USD) index(quarterly_JPY_USD) <- as.yearqtr(index(quarterly_JPY_USD)) head(quarterly_JPY_USD) ex <- merge(quarterly_NOK_USD,quarterly_JPY_USD) head(ex) summary(ex)