assembleNiObject: Assemble Data Set

View source: R/assembleNiObject.R

assembleNiObjectR Documentation

Assemble Data Set

Description

Assembles and structures data into a complete and consistent data set for calculating the Nature Index or thematic indices.

Usage

assembleNiObject(
  inputData = NULL,
  indicators = NULL,
  referenceValues = NULL,
  indicatorObservations = NULL,
  ICunits = NULL,
  BSunits = NULL,
  ecosystems = NULL,
  NIunits = NULL,
  predefNIunits = c(allArea = T, parts = F, counties = F),
  indexType = "ecosystem",
  part = "ecosystem",
  total = "total",
  partOfTotal = 0
)

Arguments

inputData

list with elements named

[[1]] "indicators",
[[2]] "referenceValues",
[[3]] "indicatorObservations",
[[4]] "ICunits",
[[5]] "BSunits",
[[6]] "ecosystems",
[[7]] "NIunits",

where the second and third elements are lists, while the others are data.frames. The last two element, ecosystems and NIunits, may be omitted or set to NULL. For example lists of class niDataImport.

indicators

data.frame containing indicator characteristics.

referenceValues

list containing reference value characteristics.

indicatorObservations

list containing indicator observations characteristics.

ICunits

data.frame containing ICunits characteristics.

BSunits

data.frame containing BSunits characteristics.

ecosystems

data.frame containing ecosystems characteristics.

NIunits

data.frame containing characteristics of user defined NIunits.

predefNIunits

named logical vector defining NIunits to be associated with the data set. Default settings are c(allArea = T, parts = F, counties = F)

indexType

character. Valid indexTypes are "ecosystem" (default), "thematic", "thematic per ecosystem".

part

character, one of c("ecosystem","marine","terrestrial"). Numerator variable in criterion for selecting BSunits.
"ecosystem": area of major ecosystem in BSunit.
"marine": marine area
"terrestrial": terrestrial area.

total

character, one of c("marine","terrestrial","total"). Denominator variable in criterion for selecting BSunits.
"total": total area of BSunit.

partOfTotal

numerical scalar in [0,1]

Details

assembleNiObject assembles and restructures a data set into a list of class niInput or a list of such lists. Most of the data are typically imported from the Nature Index database by use of importDatasetApi, except the delineation of NIunits (see below). niInput objects have the particular structure and format required for data input to the function calculateIndex.

NIunits are geographical areas for which the indices are to be calculated. NIunits may be defined in two ways, either by choosing from predefined units (argument predefNIunits), and/or entered as a data.frame with 'user defined' units (argument NIunits). The data.frame should contain variables named NIunitName and BSunitId naming NIunits and defining them in terms of BSunits.

The data set to be assembled may be entered either as a list assigned to the argument inputData containing all data elements (see Arguments above), or as several objects, one for each element, assigned to other function arguments.

The structure of the assembled data set depends on what type of index to be calculated (argument indexType): the Nature Index for major ecosystem(s) (indexType = "ecosystem", default), a thematic index (indexType = "thematic"), or a thematic index calculated for a set of major ecosystems (indexType = "thematic per ecosystem").

Parameters part, total, and partOfTotal may be used to restrict the data set to BSunits satisfying: part/total > partOfTotal, where part and total are names of variables in the BSunits data.frame containing area data.

assembleNiObject calls checkInputData to check if the data set contains all necessary information for calculating the Nature Index, and whether the data are consistent.

assembleNiObject also calls elicitate to elicitate all observations in the data set that are not given as custom distributions.

Value

A list of class niInput with elements

[[1]] indicators data.frame with indicator data.
[[2]] ICunits integer BSunit x indicator matrix of ICunits.
[[3]] BSunits data.frame of BSunit data.
[[4]] referenceValues data.frame of reference values.
[[5]] indicatorValues list of data.frames of indicator values.
[[6]] NIunits 0/1 BSunit x NIunit matrix of NIunits.

Author(s)

Bård Pedersen

See Also

checkInputData, elicitate, and calculateIndex.
The vignette objectsInNIcalc gives a more detailed description of niDataImport and niInput lists.

Examples

## Not run: 
carnivoreImport <- importDatasetApi(
     username = "...",
     password = "...",
     indic = c("Jerv","Gaupe","Ulv"),
     year = c("1990","2000","2010","2014","2019"))
carnivoreInput <- assembleNiObject(inputData = carnivoreImport,
                    predefNIunits = c(allArea = T, parts = T, counties = F),
                    indexType = "thematic")

mountainImport <- importDatasetApi(
     username = "...",
     password = "...",
     eco = "Fjell",
     year = c("1990","2000","2010","2014","2019"))
mountainInput <- assembleNiObject(inputData = mountainImport,
                    predefNIunits = c(allArea = T, parts = T, counties = F),
                    indexType = "ecosystem",
                    part = "ecosystem",
                    total = "terrestrial",
                    partOfTotal = 0.2))

## End(Not run)


NINAnor/NIcalc documentation built on Oct. 26, 2023, 9:37 a.m.