Skip to content
Advertisement

Find first occurance within a group of groups

I have a table with 5 columns.

I want to find the % received of the last date and first occurance of date_rec. Output required:

Advertisement

Answer

In R, we can do slice after grouping by ‘Country’, ‘Flow’

The above assumes that the ‘Date’ are ordered (in the OP’s example it is already ordered). If not, then convert to Date class and use which.max

data

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement