[R] how to allign data

PIKAL Petr
Thu, 02 Aug 2018 12:23:33 -0000

Dear all

Before I start to reinvent wheel I would like to ask you if you have some easy
solution for aligning data

I have something like this
x<-1:100
set.seed(42)
y1<-c(runif(20)+1, 1.2*x[1:80]+runif(80))
y2<-c(runif(40)+1, 1.2*x[1:60]+runif(60))

plot(x,y1)
points(x,y2, col=2)

with y increase starting at various x.

I would like to allign data so that the increase starts at the same x point,
something like

plot(x,y1)
points(x[-(1:20)]-20,y2[-(1:20)], col=2)

I consider using strucchange or segmented packages to find break(s) and
"shift" x values according to this break. But maybe somebody already
did similar task (aligning several vectors according to some common breakpoint)
and could offer better or simpler solution.

Best regards.
Petr
Osobn? ?daje: Informace o zpracov?n? a ochran? osobn?ch ?daj? obchodn?ch
partner? PRECHEZA a.s. jsou zve?ejn?ny na:
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about
processing and protection of business partner?s personal data are available on
website: https://www.precheza.cz/en/personal-data-protection-principles/
D?v?rnost: Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a
podl?haj? tomuto pr?vn? z?vazn?mu prohl??en? o vylou?en? odpov?dnosti: