Dear R-studio community.

I am trying to create a subset of some data, but given the nature of the data i need certain conditions to be met.

The problem is that each of my rows contain a single payment, this payment has a variable specifying a contact number. For certain customers there are multiple payments which will fall in different rows, but they will be labelled with the same contact number.

Therefore, i need the subset to take into consideration that if it selects one payment from one contact number, it needs to include all other rows (payments) containing that contact number.

See an example of customer 18445 below. I need a subset to include all 9 payments that have been made under this contact number, if it is randomly selected.

I hope this makes some sense,

Many thanks,

Naja