Thank you for your time. I have the following data (fragment). It from the longitudinal data converted into a large-format file of the status of work, each column is one month, each row is a separate one.
Code:
j1992_12 = c(1, 10, 1, 7, 1, 1)
j1993_01 = c( 1, 1, 1, NA, 3, 1)
j1993_02 = c( 1, 1, 1, NA, 3, 1)
j1993_03 = c( 1, 8, 1, NA, 3, 1)
j1993_04 = c( 1, 8, 1, NA, 3, 1)
j1993_05 = c( 1, 8, 1, NA, 3, 1)
j1993_06 = c( 1, 8, 1, NA, 3, 1)
j1993_07 = c( 1, 8, 1, NA, 3, 1)
j1993_08 = c( 1, 8, 1, NA, 3, 1)
j1993_09 = c( 1, 8, 1, NA, 3, 1)
j1993_10 = c( 1, 8, 1, NA, 3, 1)
j1993_11 = c( 1, 8, 1, NA, 3, 1)
j1993_12 = c( 1, 8, 1, NA, 3, 1)
j1994_01 = c( 1, 8, 1, 7, 3, 1)
DF93= data.frame(j1992_12, j1993_01, j1993_02, j1993_03, j1993_04, j1993_05, j1993_06, j1993_07, j1993_08, j1993_09, j1993_10, j1993_11, j1993_12, j1994_01)
Output:
j1992_12 j1993_01 j1993_02 j1993_03 j1993_04 j1993_05 j1993_06 j1993_07 j1993_08 j1993_09 j1993_10 j1993_11 j1993_12 j1994_01
R1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R2 10 1 1 8 8 8 8 8 8 8 8 8 8 8
R3 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R4 7 NA NA NA NA NA NA NA NA NA NA NA NA 7
R5 1 3 3 3 3 3 3 3 3 3 3 3 3 3
R6 1 1 1 1 1 1 1 1 1 1 1 1 1 1
My desire is to check the appearance of 12-month direct “NA”, as in line R4. I would then like to check if the last year value (j1992_12) has the same value as the first appearance of the next year ((j1994_01). If so, I believe that there have been no changes in the working status, and therefore all 12 months should receive the value given last month of the year, if not, everything should remain intact.
The method so far:
DF93_2 = DF93
DF93_2[,2:13] <- ifelse (is.na( DF93[,2:13]) && (DF93[,1]==DF93[,14]), DF93[,1] , DF93[,2:13])
, , , . R ?
DF93_2[,2] <- ifelse (is.na( DF93[,2:13]) && (DF93[,1]==DF93[,14]), DF93[,1] , DF93[,2])
- , R, .
! , WIDE . (18 , 1992 , 2010 ), , , .
, 12 NA . . - , , . !