My data set is composed as below.
x y
0
0 0
2 2
2
4
2
7 7
I want to merge x and y variable like this
x
0
0
2
2
4
2
7
That is, I want to fill x variable values with y variable values if x are missing. If there is no missing in both x and y variables two values are always same.
Another variant
x = ifelse(is.na(x), y,x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With