The answers to my last question helped me understand the dplyr
n()
. But I still couldn't apply to the problem I am trying to solve. So, here I am posting the data and actual problem. The data looks as follows
finalCalledPartyNumber Call Day Call Date Block Answered Call Duration Opty ID Opty Created Date BC ID
19183598259 Monday 2016-12-05 12:26:46 Block 2(12:30 pm) 1 5 1234 <NA> <NA>
17135796188 Monday 2016-12-05 12:18:24 Block 2(12:30 pm) 1 16 <NA> <NA> 3456
19183598259 Monday 2016-12-05 15:43:33 Block 4(5:30 pm) 1 10 <NA> <NA> 4567
17135796188 Tuesday 2016-12-06 11:53:50 Block 2(12:30 pm) 1 85 <NA> <NA> 5566
19014741000 Tuesday 2016-12-06 12:00:11 Block 2(12:30 pm) 1 42 6789 <NA> <NA>
19014741000 Tuesday 2016-12-06 10:43:20 Block 2(12:30 pm) 1 58 2345 <NA> <NA>
BC Created Date
<NA>
<NA>
<NA>
<NA>
<NA>
<NA>
For each finalCalledPartyNumber
, I want to count the number of times each finallCalledPartyNumber
was called, number of Opty ID
and BC ID
. The dataset is huge and <NA>
just means no Opty ID
or BC ID
was created.
The Output:
finalCalledPartyNumber n_opty n_BC n_calls
19183598259 1 1 2
17135796188 0 2 2
19014741000 2 0 2
I appreciate your help. Thank you.