Description Usage Arguments Details Value Examples
View source: R/pan_dummy_dates.R
Create a dummy panel over time from data on events with start and end dates.
Codes any month, quarter, or year (depending on freq
) during which an
event takes place is dummy coded as 1
.
1 2 3 4 5 6 7 8 9 10 | pan_dummy_dates(
x,
g,
col_start,
col_end,
freq = c("m", "q", "y"),
t_name,
d_name,
alt_end = NULL
)
|
x |
A |
g |
An atomic character, name of the panel group variable in |
col_start |
Atomic character, name of the column of start dates in
|
col_end |
Atomic character, name of the column of end dates in |
freq |
Atomic character, the frequency of the resulting panel. One of
|
t_name |
An atomic character, name of the panel time variable in the
resulting |
d_name |
An atomic character, name of the panel group variable in the
resulting |
alt_end |
Atomic numeric, alternative last period for resulting panel.
If |
Currently supported are yearly, quaterly, and monthly data.
A data.frame
or data.table
depending on the input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | x <- data.frame(
grp = rep(c("A", "B"), each = 3),
start_month = zoo::as.yearmon(
c("2000-01-01", "2002-05-01", "2003-12-01", "2000-06-01", "2003-01-01",
"2006-01-01")
),
end_month = zoo::as.yearmon(
c("2000-05-01", "2003-02-01", "2004-03-01", "2001-06-01", "2005-07-01",
"2008-01-01")
)
)
pdt <- pan_dummy_dates(
x, "grp", "start_month", "end_month", "m", "yearm", "dummy",
zoo::as.yearmon("2008-12-01")
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.