When I visualized my data, it had a series of periodicities in row. But Randomforest imputing and PCA imputing create outlier.
Main problem :
So i want to average on both sides in row. When the NA value of the nth column occurs, the average of n-1 column and n+1 column impute corresponding row.
Sub problem
But first column and last column doesn't have
n-1orn+1, therefore i will take n+1 or n-1.(don't worry, deviation of row is very small.)It occur na value in row continuosly. It also take
n-1orn+1.
EX:
tr <- structure(list(A_1 = c(NA,2,3,4,5), A_2 =c(4,5,6,NA,8), A_3 = c(7,9,NA,10,11),
A_4 = c(10,12,NA,13,NA), A_5 =c(12,NA,14,15,16), A_6 = c(13,15,15,16,17)),
row.names = c(NA, -5L),class = "data.frame")
> tr
A_1 A_2 A_3 A_4 A_5 A_6
1 NA 4 7 10 12 13
2 2 5 9 12 NA 15
3 3 6 NA NA 14 15
4 4 NA 10 13 15 16
5 5 8 11 NA 16 17
Desired output
> tr
A_1 A_2 A_3 A_4 A_5 A_6
1 4 4 7 10 12 13
2 2 5 9 12 13.5 15
3 3 6 6 14 14 15
4 4 7 10 13 15 16
5 5 8 11 13.5 16 17