Pergunta de entrevista da empresa Flatiron Health

How would you approach this problem using R?