TimeFill: Creates a continuous Unit-Time-Dummy data frame from a data...

Description Usage Arguments Value Examples

Description

Creates a continuous Unit-Time-Dummy data frame from a data frame with Unit-Start-End times

Usage

1
2
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 TimeFilled.

NewTimeVar

a character string specifying the name of the new time variable. The default is Time.

KeepStartStop

logical indicating whether or not to keep the StartVar and EndVar variables in the output data frame.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 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, ]

DataCombine documentation built on May 2, 2019, 11:26 a.m.