leads_and_lags: leads_and_lags can be used to add in leads or lags of a...

Description Usage Arguments Value Examples

Description

leads_and_lags can be used to add in leads or lags of a variables

Usage

1
leads_and_lags(df, variable, foo, x)

Arguments

df

data frame

variable

the variable to lead or lag

foo

the function to use (lead or lag)

x

the number of leads or lags to include

Value

a leaded or lagged vector to data frame

Examples

1
2
3
4
5
edat <- edat %>%
group_by(region,fishery,gear) %>%
 arrange(year) %>%
 leads_and_lags(quo(`average price`),lag,0:5) %>%
 leads_and_lags(quo(`average price`),lead,1:5)

DanOvando/demons documentation built on May 6, 2019, 1:22 p.m.