Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Is there method in R to replace values in one data frame with a related value from another data frame?

$
0
0

I need to replace the values in one data frame with values from another data frame. I am trying to find the simplest way to do so but I may be over thinking it.

Here is a sample of the data from DF1:

season  article 1st_booking 2nd_booking
SS20    EF0647  2019-06-25  2019-07-09  
SS20    059611  2019-07-30  2019-08-13  
SS20    EG3208  2019-10-29  <NA>    
SS20    EF9348  2019-10-29  2019-11-12  
SS20    EE4609  2019-08-27  2019-10-29  
SS20    EF7610  2019-09-24  2019-10-29  
SS20    EH1307  2019-09-24  2019-10-29  
SS20    EH1308  2019-09-24  2019-10-29  
SS20    EH1309  2019-09-24  2019-10-29  
SS20    EH1310  2019-09-24  2019-10-29  

And from DF2:

season  article order_cutoff  booking_deadline
SS20    EF0647  2019-06-25  2019-06-07  
SS20    EF0647  2019-07-09  2019-06-07  
SS20    EF0647  2019-12-10  2019-11-08  
SS20    059611  2019-07-30  2019-07-12  
SS20    059611  2019-08-13  2019-07-12  
SS20    059611  2019-10-08  2019-09-06  
SS20    EG3208  2019-10-29  2019-10-11  
SS20    EF9348  2019-10-29  2019-10-11  
SS20    EF9348  2019-11-12  2019-10-11  
SS20    EF9348  2019-11-26  2019-11-08

Note that 1st_booking & 2nd_booking from DF1 are called 'order_cutoff' in DF2. What I would like to do is in DF1, replace the values in columns 1st_booking & 2nd_booking with the related booking_deadline from DF2. Tried to do a merge but I don't want to create a new column - just replace the values in DF1 with the values in DF2


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>