TimeExpand: Expands a data set so that it includes an observation for...

Description Usage Arguments Examples

View source: R/FillIn.R

Description

Expands a data set so that it includes an observation for each time point in a sequence. Works with grouped data.

Usage

1
TimeExpand(data, GroupVar, TimeVar, begin, end, by = 1)

Arguments

data

a data frame.

GroupVar

the variable in data that signifies the group variable.

TimeVar

the variable in data that signifies the time variable. The sequence will be expanded between its minimum and maximum value if begin and end are not specified.

begin

numeric of length 1. Specifies beginning time point. Only relevant if end is specified.

end

numeric of length 1. Specifies ending time point. Only relevant if begin is specified.

by

numeric or character string specifying the steps in the TimeVar sequence. Can use "month", "year" etc for POSIXt data.

Examples

1
2
3
4
Data <- data.frame(country = c("Cambodia", "Camnodia", "Japan", "Japan"),
                   year = c(1990, 2001, 1994, 2012))

ExpandedData <- TimeExpand(Data, GroupVar = 'country', TimeVar = 'year')

DataCombine documentation built on May 30, 2017, 2:52 a.m.