I am trying to ggplot D2 on the same figure as of D1. I, however, do not have data for the Variable X in D2 data.frame. How i can plot D2 on its respective facets of D1 plot? these plots represent data for 2011 and 2014 so i would like to have legends for the line to differentiate which line represent which year data.
library(tidyverse)
set.seed(1500)
D1 <- data.frame(Day = 1:8, A = runif(8, 2,16), S = runif(8, 3,14), X = runif(8, 5,10), Z = runif(8, 1,12), Year = rep("2011",8))
D2 <- data.frame(Day = 1:8, A = runif(8, 2,14), S = runif(8, 1,13), Z = runif(8, 3,14), Year = rep("2014",8))
# plotting D1
D1 %>% gather(-c(Day, Year), key = "Variable", value = "Value") %>%
ggplot( aes(x = Day, y = Value))+
geom_line()+facet_wrap(~Variable, scales = "free_y", nrow=2)
# Plotting D2 on top ?
