I have column KIRJED1, where are all statuses of person.
Column VER1 represents the day, when record was made.
In the column KIRJED2 there are values of column KIRJED1 such that if there are several of the same value in a row, only the first one is written.
In the column KIRJED3 is KIRJED2, where “K” and “O” get value “R” and “A” and “V” get “A”.
In the column KIRJED4 uses same idea of the column KIRJED3 as KIRJED2 did from KIRJED1.
kirjed1<- c("K,K,K,K,K,K,K,A,A,K,K,K,K,A,K,O,A,A,K", "
K,K,A,K,K", "K,O,A,V,K")
kirjed2 <- c("K,A,K,A,K,0,A,K","K,A,K", "K,O,A,V,K")
ver1 <- c("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19", "49,106,130,150,167", "1,6,39,103,135")
kirjed3 <- c("R,A,R,A,R,R,A,R","R,A,R", "R,R,A,A,R")
kirjed4<- c("R,A,R,A,R,A","R,A,R", "R,A,R" )
dt <- data.frame(KIRJED1 = kirjed1, VER1 = ver1, KIRJED2= kirjed2, KIRJED3=kirjed3, KIRJED4= kirjed4)
# KIRJED1, VER1, KIRJED4
# 2 K,K,A,K,K 49,106,130,150,167 R,A,R
# 3 K,O,A,V,K 1,6,39,103,135 R,A,R
But how can I get now column VER2 which takes days corresponding to these values that are in KIRJED4?
old column value "1,6,39,103,135"
new column value "1,39,135"
ver2 <- c("1,8,10,14,15,17,19", "49,130,150", "1,39,135")
# KIRJED1, VER1, KIRJED4, VER2
# 2 K,K,A,K,K 49,106,130, 150,167 R,A,R 49,130, 150
# 3 K,O,A,V,K 1,6,39,103,135 R,A,R 1,39,135
I have tried multible things.