I want to replace the NA values in my df using tidyverse, the values I want should be caculated from other cols:
input:
ID, X1, X2, X3,
"A", 0.96, NA, 0.97,
"B", 1.00, NA, 1.01,
"C", 0.98, 0.03, NA,
"A", 1.00, NA, 1.00,
"D", NA, 0.05, 0.99,
My wish is to find in each row which variable of all three X1, X2, X3 is NA and to calcualte it with the sum of the other two variables
output:
ID, X1, X2, X3,
"A", 0.96, 1.93, 0.97,
"B", 1.00, 2.01, 1.01,
"C", 0.98, 0.03, 1.01,
"A", 1.00, 2.00, 1.00,
"D", 1.04, 0.05, 0.99,
Thanks!