Learn R Programming

FAOSTAT (version 1.6)

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

Run this code
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)

Run the code above in your browser using DataLab