2016年8月29日月曜日

sort out call data with "unique" function.

when call data is as below

       number status
1  0975357001  FDISC
2  0975357001  FDISC
3  0975357001  FDISC
4 08037573628  FDISC
5  0458583634  FDISC
6  0454315424  FDISC
     <skipped>
695  0999255908   ABAN
696  0266735287    ANS
697  0995252908   ABAN
698 08035447511  FDISC
699 08043657563  FDISC
700 09027935501  FDISC

for(i in unique(calldata$number)){cat(i);cat(" ");
cat(calldata$status[calldata$number==i]);
cat("\n")}

will return the sequence of returncode with the unique call number.

0727229518 1
32072 6 6
09086909233 2
09077857629 1
08035447613 5
09025935528 5

for(i in unique(calldata$number)){cat(i);print(calldata$status[calldata$number==i])}

will return status code in the original data instead of numeric ones.

09086909233[1] ANS
Levels: ABAN ANS CONN FBUSY FDISC OTHER
09077857629[1] ABAN
Levels: ABAN ANS CONN FBUSY FDISC OTHER
08035447613[1] FDISC
Levels: ABAN ANS CONN FBUSY FDISC OTHER
09025935528[1] FDISC
Levels: ABAN ANS CONN FBUSY FDISC OTHER

0 件のコメント: