I want to replace missing values or character values in a data with the row mean. for example in the data below, the missing values are denoted with “U” and I want to replace all the “U” from p1 to p6 with the values in the “ave” column for each row. There are thousands of the rows to replace.
num p1 p2 p3 p4 p5 p6 ave
L1 0 10 1 U 0 -10 1.3
L2 10 1 10 10 U 10 7.1
L3 U 10 10 U 1 -10 3.1
Here’s one approach: