Covid-19 Data in R - Setting Day 0 when number of cases equals n = 100 I am wondering if anyone might be able to provide me with some guidance regarding how I should reformat data related to Covid-19. 
I have the country data already and have been working with it for a few days, but I can't recall or simply don't know how to make it so that I can (in r) set Day 0 equal to the day that the n'th death was measured in a country, much like in the image that I have attached below. 
My knowledge of working with time series in R is rather limited and I have not been able to find the answers online. I've tried some examples, but to little to no avail and they're definitely not worth sharing. 

I am using data from the Our World in Data database: https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv
Any help would be greatly appreciated! Thanks!
 A: The exercise you are seeking to perform can be done using the commands in the dplyr package.  It is a good idea to learn to become proficient with using data frames and manipulations in this package.  I will get you started by showing you how you can get the data into a form where you have a listed number of days since the total deaths in each location reached a specified threshold.

The first thing we need to do here is to import the data from the stated location.  Since the data file is a .csv file, this is done using the read.csv function.  The dates are initially imported as character strings, which is not a useful format for our purposes.  To deal with this we create a vector of the dates in proper date format, and then put this back into the data frame as an integer representation.  (Note that in this format, each day corresponds to a particular integer.)
#Import the data
PATH       <- 'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/';
FILE       <- 'owid-covid-data.csv';
DATA <- read.csv(file = paste0(PATH, FILE), 
                 header = TRUE, sep = ',',
                 stringsAsFactors = FALSE);

#Create dates and date-integers
DATE <- as.Date(DATA$date, format = '%Y-%m-%d');
DATA$date_integer <- as.integer(DATE);

This gives you a data frame DATA with 12,246 observations and 17 variables.  The variable date_integer is constructed to give the dates as integer values.  The next step is to create a table of values showing the date at which each location first gets to a specified threshold for the number of deaths.  We can do this by creating a variable DEATH_THRESHOLD and filtering the observations so that we only include observed values with total deaths at least as large as this threshold, and then we take the minimum date_integer over each location.  We will refer to the "cross-over" date as the date when the minimum number of total deaths first occurred.
#Create data frame for crossing dates
library(dplyr);
DEATH_THRESHOLD <- 5;
CROSS <- DATA %>% group_by(location) %>% 
                  filter(total_deaths >= DEATH_THRESHOLD) %>% 
                  summarise(date_cross = min(date_integer))  %>% 
                  as.data.frame();

With DEATH_THRESHOLD == 5 we get a data frame CROSS with 131 locations, showing the date (as an integer) when the location first experienced the stipulated number of total deaths.  This means that only 131 of the locations in the initial data has reached the total death threshold under consideration here.  We can now use this information to create a new data frame filtered down to these countries, with a variable giving the number of days since the "cross-over" date.
#Add cross-over dates and time since this date to data frame
DATA_REDUCED <- merge(DATA, CROSS, by = 'location') %>% 
                mutate(days_since = date_integer - date_cross) %>%
                filter(days_since >= 0) %>% 
                arrange(location, days_since) %>%
                as.data.frame();

The data frame DATA_REDUCED gives you the data that has occurred at each location since the total deaths became at least as large as the specified threshold.  Note that this removes some locations entirely, since some of the locations have not yet had this many deaths.  In the case here where I have set the death-threshold to five total deaths, there are 3,116 observations remaining in the data.  The number of days since the death threshold was reached is given by the days_since variable
