I have a data set like this
temp <- structure(list(col_1 = c("", "P9603", "", "", "11040",
"80053"), col_2 = c("84484", "80061", "", "80061", "A0428", "85025"
), col_3 = c("V2632", "82310", "", "", "", "86357"), col_4 = c("J1170",
"84305", "62311", "80061", "", ""), col_5 = c("", "86708", "J0690",
"", "", "")), .Names = c("col_1", "col_2", "col_3", "col_4",
"col_5"), class = c("data.table", "data.frame"))
col_1 col_2 col_3 col_4 col_5
1: 84484 V2632 J1170
2: P9603 80061 82310 84305 86708
3: 62311 J0690
4: 80061 80061
5: 11040 A0428
6: 80053 85025 86357
Is there a possibility to shift the columns like this
col_1 col_2 col_3 col_4 col_5
1: 84484 V2632 J1170 #LEFT SHIFT 1
2: P9603 80061 82310 84305 86708 #NO CHANGE
3: 62311 J0690 #LEFT SHIFT 3
4: 80061 80061 #LEFT SHIFT 1 FOR FIRST ITEM,
#LEFT SHIFT 2 FOR 2ND ITEM
5: 11040 A0428 #NO CHANGE
6: 80053 85025 86357 #NO CHANGE
I am shifting columns left, if the value on left is empty