Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

grConstruct

Construct Growth rate


Description

A function for constructing growth rate variables.

Usage

grConstruct(data, origVar, newVarName = NA, type = c("geo", "ls", "ch"), n = 1)

Arguments

data

The data frame containing the data

origVar

The variable in which the growth is to be calculated

newVarName

The name assigned to the new variable, if missing then .SC/.SH/.GR will be appended depending on the type of construction.

type

The type of growth rate, can be least squares or geometric

n

The period for the growth rate to be calculated (Refer to the lsgr or the geogr functions.)

Value

A data frame containing the computed growth rate.

Examples

test.df2 = data.frame(FAOST_CODE = rep(c(1, 5000), each = 5),
                       Year = rep(1990:1994, 2),
                       a = rep(1:5, 2), b = rep(1:5, 2))
grConstruct(test.df2, origVar = "a", type = "geo", n = 1)
grConstruct(test.df2, origVar = "a", type = "geo", n = 3)
grConstruct(test.df2, origVar = "a", type = "geo", n = 5)

FAOSTAT

Download Data from the FAOSTAT Database

v2.2.1
GPL (>= 2)
Authors
Michael C. J. Kao <michael.kao@fao.org>, Markus Gesmann, Filippo Gheri
Initial release
2020-11-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.