0
I’m starting with programming and I’m trying to plot a graph overlaying data extracted from two dataframes.
The code is as follows::
#Real Gross Domestic Product - GDP
USgdp <- read_csv('GDP.csv')
colnames(USgdp) <- c("Date","GDP")
#ISM PMI Composite Index
USpmi <- Quandl('ISM/MAN_PMI')
#GDP
gGDP <- ggplot(data = USgdp,
aes(x = Date, y = GDP,
colour = GDP)) +
labs(title = "U.S. Real Gross Domestic Product", x = "Date", y = "GDP") +
theme_minimal() +
guides(fill = "none", colour = "none") +
geom_bar(stat = 'Identity')
#ISM PMI
gPMI <- ggplot(data = USpmi,
aes(x = Date, y = PMI,
colour = "darkred")) +
guides(fill = "none", colour = "none") +
geom_line(size = 1)
The zero for the line graph reading corresponds to the value 50 of the y-axis.
How can I overlay these two charts by aligning their respective zeros as in this example?
I appreciate the help!
Welcome to Sopt. To have your question properly answered, provide a minimum, complete and verifiable example. If your question does not depend on your data, use a built-in set in R, or generate sample data (including the code in the question). Check this post on how to ask a reproducible question in R for more details.
– Carlos Eduardo Lagosta