TimeFill {DataCombine} | R Documentation |
Creates a continuous Unit-Time-Dummy data frame from a data frame with Unit-Start-End times
Description
Creates a continuous Unit-Time-Dummy data frame from a data frame with Unit-Start-End times
Usage
TimeFill(data, GroupVar, StartVar, EndVar, NewVar = "TimeFilled",
NewTimeVar = "Time", KeepStartStop = FALSE)
Arguments
data |
a data frame with a Group, Start, and End variables. |
GroupVar |
a character string naming the variable grouping the units within which the new dummy variable will be found. |
StartVar |
a character string indicating the variable with the starting times of some series. |
EndVar |
a character string indicating the variable with the ending times of some series. |
NewVar |
a character string specifying the name of the new dummy variable for the series. The default is |
NewTimeVar |
a character string specifying the name of the new time variable. The default is |
KeepStartStop |
logical indicating whether or not to keep the |
Value
Returns a data frame with at least three columns, with the GroupVar
, NewTimeVar
, and a new dummy variable with the name specified by NewVar
. This variable is 1
for every time increment between and including StartVar
and EndVar
. It is 0
otherwise.
Examples
# Create fake data
Country = c('Panama', 'Korea', 'Korea', 'Germany', 'Finland')
Start = c(1995, 1980, 2004, 2000, 2012)
End = c(1995, 2001, 2010, 2002, 2014)
Data <- data.frame(Country, Start, End)
# TimeFill
FilledData <- TimeFill(Data, GroupVar = 'Country',
StartVar = 'Start', EndVar = 'End')
# Show selection from TimeFill-ed data
FilledData[90:100, ]