Home > Back-end >  Sequentially update a vector in R
Sequentially update a vector in R

Time:04-27

Hello I have a vector such as

x<-c(**131144**,**1311605**,1311766,1312289,1312804) in R

And then another data frame like:

v1     , v2
**131144,1283758**
**1283758,19527672**
**1311605,19950311**
198151,37268685
**19950311,35307140**
11281862,11292508
35261079,26296073
625349,37306860
84255273,84259752

I would like to end up with a final vector like this one

x<-c(**19527672**,**19950311**,1311766,1312289,1312804)

Is like to iteratively searching for a value and when a match is found updating it and then keep searching for the updated value until no match found.

Thks in advance.

CodePudding user response:

Alittle tweak to the enter image description here

  • Related