Case1: Input
ST_DATE ND_DATE LO_NO ACTV_CODE ACTV_AMT AB_NO FEATURE_CODE L_NU
7/27/16 7/27/16 265 O 15 1 INTEREST 855
7/27/16 7/27/16 265 O 14 1 INTEREST 855
Expected output
ST_DATE ND_DATE LO_NO ACTV_CODE ACTV_AMT AB_NO FEATURE_INTEREST L_NU
7/27/16 7/27/16 265 O 29 1 2 855
Case2: Input (my code is working for case2 but throwing error for case1)
ST_DATE ND_DATE LO_NO ACTV_CODE ACTV_AMT AB_NO FEATURE_CODE L_NU
7/27/16 7/27/16 265 O 15 1 INTEREST 855
7/27/16 7/27/16 265 O 14 1 INSTALLMENT 855
ST_DATE ND_DATE LO_NO ACTV_CODE ACTV_AMT AB_NO INTEREST INSTALLMENT L_NU
7/27/16 7/27/16 265 O 29 1 1 1 855
install_cntdup_less1 <- install_BAN %>%
group_by(AB_NO,LO_NO,L_NU)%>%
mutate(ACTV_AMT = sum(ACTV_AMT),ftr=sum(unique(!is.na(FEATURE_CODE))))%>%
spread(FEATURE_CODE,ftr,fill = 0)%>%
slice(which.min(as.Date(ST_DATE, '%Y/%m/%d')))%>%
slice(which.max(as.Date(ND_DATE, '%Y/%m/%d')))
Getting the below error
Error: Duplicate identifiers for rows (29424, 29425, 29426), (7415, 7416), (30120, 30121)
tried introducing unique ID as mentioned below link but it is messing my output Spread with duplicate identifiers (using tidyverse and %>%)
mutate(ind = row_number()) %>%
I am unable to understand what to do can anyone help me in resolving the error. It may seem duplicate question but it is not