Last active
August 29, 2015 14:17
-
-
Save CliffordAnderson/a25ffb263892fca8d577 to your computer and use it in GitHub Desktop.
Compare the annual GDP growth in China and the United States
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load libraries | |
library(ggplot2) | |
library(Quandl) | |
# Load datasets from Quandl | |
USA <- Quandl("WORLDBANK/USA_NY_GDP_MKTP_KD_ZG", authcode="[TOKEN") | |
China <- Quandl("WORLDBANK/CHN_NY_GDP_MKTP_KD_ZG", authcode="[TOKEN") | |
# Merge datasets into single table | |
Comp <- China | |
Comp$USA <- USA$Value | |
names(Comp)[2] <- "China" | |
# Build line plot | |
plot <- ggplot(Comp, aes(x=Date)) | |
plot <- plot + geom_line(aes(y = USA), color="red") | |
plot <- plot + geom_line(aes(y = China), color="blue") | |
plot <- plot + xlab(label="Year") | |
plot <- plot + ylab(label="Annual GDP Growth") | |
plot <- plot + ggtitle("Comparison Annual GDP Growth in USA and China") | |
# Display plot | |
plot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment