is_new: Find "new" entries in time series data

Description Usage Arguments Value

View source: R/is_new.R

Description

Calculates if a unit is 'new' in a region through two threshold conditions. t0 threshold refer to the current time period, t1 refer to the next. A product is given value 1 for "new" in the t0 period. In other words, if the unit is newly introduced in t1, the t0 value has a "new" value. This seems unintutive, but this makes it easier to extract the relatedness metrics for the t0-period in analysis. The input data must contain the four variables listed.

Usage

1
is_new(data, t0_threshold = 0.5, t1_threshold = 1)

Arguments

data

Data frame containing variables for time (fx year), region (fx country), unit (fx product) and rca (revealed comparative advantage or location quotient). All variables must be present. Data should follow the tidy format.

t0_threshold

Numeric of length 1. The value that rca should be below in current period, in order to be 'new'.

t1_threshold

Numeric of length 1. The value that rca should be above in next period, in order to be 'new' (only if t0_threshold also holds).

Value

data frame that contains the original values plus two new: previous_rca, which is the rca value for the region in the unit the previous time-period, and is_new, which takes the value 1 if the threshold conditions are passed, 0 if not. is_new is NA if there is no next rca value present (i.e. for all values in the latest time period).


jorgenfrost/compost documentation built on Nov. 4, 2019, 3:10 p.m.