Here I use DemocracyIncome as my dataset. It can be reached from R package pder
and the codes are as follows:
library(pder)
data("DemocracyIncome", package = "pder")
df <- na.omit(DemocracyIncome)
Part of the dataset is as:
country year democracy income sample
Angola 1965-1969 0.1200000 7.963571 0
Angola 1975-1979 0.1666667 7.642973 0
Angola 1980-1984 0.0000000 7.563512 1
Angola 1985-1989 0.0000000 7.528483 1
Angola 1990-1994 0.0000000 7.573770 1
Angola 1995-1999 0.1666667 7.132994 1
Albania 1995-1999 0.6666667 7.947575 1
Albania 2000-2004 0.5000000 8.115600 1
Argentina 1950-1954 0.4900000 8.768732 0
Argentina 1955-1959 0.3000000 8.833524 0
Argentina 1960-1964 0.6300000 8.905374 1
...
Now I want to create a new dataset using the first observation of each country, which is supposed to be
country year democracy income sample
Angola 1965-1969 0.1200000 7.963571 0
Albania 1995-1999 0.6666667 7.947575 1
Argentina 1950-1954 0.4900000 8.768732 0
...
How can I filter df and get this new dataset then?