[R] Replacing value with "1"
Saba Sehrish
sabasehrish at yahoo.com
Fri Sep 23 04:27:57 CEST 2016
Hi
I have a matrix that contains 1565 rows and 132 columns. All the observations are either "0" or "1". Now I want to keep all the observations same but just one change, i.e. whenever there is "1", the very next value in the same row should become "1". Please see below as a sample:
>df
0 0 1 0 0
NA 0 1 1 0
0 1 0 0 NA
What I want is:
0 0 1 1 0
NA 0 1 1 1
0 1 1 0 NA
I shall be thankful for the reply.
Saba
More information about the R-help
mailing list