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

Conditional cbind() on dates

$
0
0

Assume we have 2 dataframes of 2 cols and 6 rows each and we want to cbind both only when date on the left(lhs) is older than date on the right(rhs), at the same time making sure that each row has no date duplicates (in both lhs and rhs): for instance..

x = cbind(data.frame(lhs_date = seq(Sys.Date()-5, Sys.Date(),2)), letter=c("A","B","C","D","E","F") )
Y = cbind(data.frame(rhs_date = seq(Sys.Date()-5, Sys.Date(),1)), letter=c("X","Y","Y","X","J","J") )

How can we cbind or left join x to y only when lhs date < rhs date maintaining the uniqueness of each row?


Viewing all articles
Browse latest Browse all 201894

Trending Articles



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