I have two different datasets (c1 and c2), which are plotted together in one graph. both curves have different x- and y-values:
c1 = data.frame(
x=c(0,1.1,2, 3, 4, 5),
y=c(0,1.1,1.9,3.2,4.3,5.2)
)
c2 = data.frame(
x=c(0,0.3,0.9,2.1,3.2,4.2,5),
y=c(0,0.4,1.5,2.3,3.2,4.1,5.1)
)
plot(c1, type="o", col=2)
lines(c2, type="o", col=3)
Now I like to plot the residuals of the two curves (res=c1-c2) for all unique x values (unique(c(c1$x, c2$x))). This would be easy if I had the same x-values. But it seems, that I have to interpolate all missing x-values and add them to the measured dataset.
Is there an easy way for doing this in R?
How about this:
On the values
c1$x:on the values
c2$x:Or, putting it all together,