I have a data that looks like this:
SN TimeStamp MOTOR
1 1/27/20 18:00 0
2 1/27/20 18:01 NA
3 1/27/20 18:02 1
4 1/27/20 18:03 NA
5 1/27/20 18:04 0
6 1/27/20 18:05 1
7 1/27/20 18:06 NA
8 1/27/20 18:07 NA
9 1/27/20 18:08 0
Basically, my question is how can I change the NA value to its presiding value? I mean for NA in row 2, the answer would be the same as earlier row number 1 i.e. 0. For NAs at row 7 and 8, the answer would be that of row 6 which is 1. For NA at row 4, the value would be replaced by the number in row 3, which is 1.
Is it possible to program like that?
I would be thankful if anyone could help.
Thanks.