I am trying to plot three data sets that share an x axis. some of the data sets, however, have missing data and are thus of different length. I can plot them fine individually but when I try to facet them all together I get an error that the data sets contain different numbers of rows. This error only occurs when I facet the plot (which is necessary).
Any suggestions for how I could get the facet plot to accept data sets with different numbers of rows?
The code i've been using is:
ggplot()+
geom_line(data=x,aes(x=x$BIN_START,y=x$TajimaD),size=0.6,alpha=0.65,colour="skyblue1")+
geom_line(data=y,aes(x=y$BIN_START,y=y$TajimaD),size=0.3,alpha=0.85,colour="greenyellow")+
geom_line(data=z,aes(x=z$BIN_START,y=z$TajimaD),size=0.25,alpha=0.95,colour="black")+
scale_x_continuous()+
facet_grid(rows=vars(x$CHROM))+
theme_classic()+
ylab("TajimaD") +
xlab("Location (bp)")
As was suggested in a comment I have now moved all the data into a single file and added a column to indicate the population the data is from. I am still getting a similar error message: "replacement has 22588 rows, data has 7537"
ggplot()+
geom_line(data=x,aes(x=a$BIN_START,y=a$TajimaD,color=a$Population),size=0.6,alpha=0.65)+
scale_x_continuous()+
facet_grid(rows=vars(a$CHROM))+
theme_classic()+
ylab("TajimaD") +
xlab("Location (bp)")