Q:

Check if there are missing dates in a certain time range

Following dataset:
 Name   Year   more columns
 A      2000
 A      2001
 A      2002
 A      2003
 B      2000
 B      2001
 B      2003
 C      2001
 C      2002
 ....

library(data.table)
DT = rbind(use.names = FALSE, 
  data.table(Name = "A", Year = (y <- 2000:2003)), 
  data.table("B", y[-3]), 
  data.table("C", y[-c(1,4)]))

I want to get the all values from my column name that have at least one missing year between 2000-2003.
So in this example, I want to get the following values from my column name.
B because 2002 is missing and C because 2000 is missing.
I want to check if there are any years between 2000-2003 missing for all my values in my column Name.
Is there a simple way to do this?

A:

Here's a simple way using base R:
aggregate(Year ~ Name, df, FUN = function(x) all(2000:2003 %in% x))

  Name  Year
1    A  TRUE
2    B FALSE
3    C FALSE

