Learn R Programming

FAOSTAT (version 1.6)

aggCountry: Function for aggregating entities into countries

Description

The function takes a relational data.frame and computes the aggregation based on the relation specified. The defaulted aggregates entities into the United Nations Statistics Division M49 country level definition.

Usage

aggCountry(aggVar, weightVar = rep(1, length(aggVar)),
    year = "Year", data,
    relationDF = FAOcountryProfile[, c("FAOST_CODE", "MOTHER_M49_CODE")],
    aggMethod = rep("sum", length(aggVar)),
    keepUnspecified = TRUE, unspecifiedCode = 0)

Arguments

aggVar
The vector of names of variables which the aggregation will be performed
weightVar
The weighting vector if the aggregation method is weighted.mean. The vector should be the same length as the arguement aggMethod.
year
The column which indexes the time.
data
The data frame for the collapse aggregation to take place.
relationDF
A relational data.frame which specifies the territory and the mother country. At least one column or the first column must have the same name corresponding to the data.
aggMethod
The method for aggregation, currently supports sum, mean and weighted mean when the weights are supplied.
keepUnspecified
It is common that certain territories are not included in the classification in particular the disputed regions. This option controls whether these data are aggregated and kept as a seperate entity.
unspecifiedCode
The output code of the unspecified group.

Details

The length of aggVar, aggMethod, weightVar must be the same.

See Also

aggRegion