Returns top and bottom commodities in terms of aggregate production, harvested area, and/or value of production.

genRank(var = "h", by = "ISO3", ...)

Arguments

var
one or several of "harvested area", "production", or "value of production". These argument can be abbreviated to "h", "p" or "v". May be expanded in the future to include additional sub-groups of indicators.
by
by default returns aggregate production across all selected countries. by may be specified to return aggregates across sub-zones (e.g. across provinces, districts, agro-ecological zones, etc.), see examples.
...
optional arguments passed to hcapi, e.g. iso3 and wkt

Value

data.table(s) of commodities ranked from top to bottom

Details

API call: rank commodities in Angola and Mozambique by harvested area and production

$ curl http://hcapi.harvestchoice.org/ocpu/library/hcapi3/R/genRank/json \ -d '{"var" : ["h", "p"], "iso3" : ["AGO", "MOZ"]}' \ -X POST -H 'Content-Type:application/json'

API call: rank commodities across Angola's agro-ecological zones by production

$ curl http://hcapi.harvestchoice.org/ocpu/library/hcapi3/R/genRank/json \ -d '{"var" : "p", "iso3" : "AGO", "by" : "AEZ5_CLAS"}' \ -X POST -H 'Content-Type:application/json'

See also

hcapi

Examples

# Rank commodities in Angola and Mozambique by harvested area and production x <- genRank(c("h", "p"), iso3=c("AGO", "MOZ"))
#> Warning: the condition has length > 1 and only the first element will be used
#> Warning: the condition has length > 1 and only the first element will be used
#> Warning: To be consistent with reshape2's melt, id.vars and measure.vars are internally guessed when both are 'NULL'. All non-numeric/integer/logical type columns are conisdered id.vars, which in this case are columns [ADM0_NAME, ISO3.1]. Consider providing at least one of 'id' or 'measure' vars in future.
#> Error in eval(expr, envir, enclos): object 'value' not found
x
#> Error in eval(expr, envir, enclos): object 'x' not found
# Rank commodities across Angola's agro-ecological zones by production x <- genRank("p", iso3="AGO", by="AEZ5_CLAS")
#> Warning: To be consistent with reshape2's melt, id.vars and measure.vars are internally guessed when both are 'NULL'. All non-numeric/integer/logical type columns are conisdered id.vars, which in this case are columns [ADM0_NAME, AEZ5_CLAS]. Consider providing at least one of 'id' or 'measure' vars in future.
#> Error in eval(expr, envir, enclos): object 'value' not found
x
#> Error in eval(expr, envir, enclos): object 'x' not found