I have a table listing (amount, year and month) and I want to filter the rows corresponding to complete years. I.e. I want to ommit the last 4 rows of the sample dataframe I
tally()
is the equivalent of summarise(n=n())
. However, in this case you want to keep the original rows of the data frame, but filtered so that rows that are part of incomplete years are removed. @AndresT's answer will work fine, but you can also do it more concisely without an intermediate step of creating a column to count the number of rows for each group:
df %>% group_by(year) %>% filter(n()==12)