importDatasetApi: Import Dataset

View source: R/importDatasetApi.R

importDatasetApiR Documentation

Import Dataset

Description

Imports a data set from the Norwegian Nature Index database via API

Usage

importDatasetApi(
  username = NULL,
  password = NULL,
  eco = NULL,
  indic = NULL,
  year = NULL,
  norwegian = TRUE,
  refYearCode = 0
)

Arguments

username

character. Your username for accessing the NI database.

password

character. Your password for accessing the NI database.

eco

character; optional vector specifying ecosystems to include in the dataset. Ignored with nonempty indic.

indic

character; optional vector specifying indicators to include in the dataset.

year

character; optional vector specifying years to include in the dataset.

norwegian

logical; use norwegian (TRUE, default) or english (FALSE) names for indicators and ecosystems.

refYearCode

integer; code used for reference values. Defaults to 0 which is the code used in the NI database.

Details

importDatasetApi imports a complete data set for calculating the Nature Index or a thematic index by reading various tables in the NI database via the [The Nature Index Application Programming Interface](https://www8.nina.no/NaturindeksNiCalc/index.html) and returns the data set as a list of class niDataImport.

The function includes options for assembling complete data sets for an ecosystem, for e.g. subsequent calculation of the Nature Index. It also includes options for assembling a data set for a particular set of indicators, for e.g. subsequent calculation of a thematic index. Further, it includes options for selecting data from particular years, and for choosing between Norwegian (default) and English ecosystem and indicator names.

importDatasetApi contains some simple procedures for data washing. It removes from the data set

  • passive indicators and indicators with zero fidelities to ecosystems in question.

  • redundant BSunits and ICunits, i.e. units with no indicator observations from the ecosystem in question.

  • ICunits without reference values or with reference values equal zero.

  • ICunits with only missing observations or with only reference values and no other observations.

Value

A list of class niDataImport with the following elements:

[[1]] $indicators a data.frame with indicator data.
[[2]] $referenceValues a list of reference values.
[[3]] $indicatorObservations a list of indicator observations.
[[4]] $ICunits a data.frame describing ICunits.
[[5]] $BSunits a data.frame with BSunit data.
[[6]] $ecosystems a data.frame with ecosystem names and IDs.

The vignette objectsInNIcalc gives a more detailed description of niDataImport lists.

Author(s)

Bård Pedersen

See Also

getNIdata for functions called by importDatasetApi that import data from specific tables in the NI database, and niDataImport.

Examples

## Not run: 
# Import data for the calculation of a Nature Index for forests in Norway
# covering the years 1990, 2000, 2010, 2014, 2019.

forestImport <- importDatasetApi(username = "your username",
                                 password = "your password",
                                 eco = "Skog",
                                 indic = NULL,
                                 year = c("1990","2000","2010","2014","2019"),
                                 norwegian = TRUE,
                                 refYearCode = 0)

# Import data for the calculation of a thematic index for game birds in Norway
# in 2000

amphibImport <- importDatasetApi(username = "your username",
                                 password = "your password",
                                 eco = NULL,
                                 indic = c("Fjellrype","Lirype","Orrfugl","Storfugl"),
                                 year = c("2000"),
                                 norwegian = TRUE,
                                 refYearCode = 0)

# Import data for the calculation of an indicator index

cormorImport <- importDatasetApi(username = "your username",
                                 password = "your password",
                                 eco = NULL,
                                 indic = c("Toppskarv"),
                                 year = c("1990","2000","2010","2014","2019"),
                                 norwegian = TRUE,
                                 refYearCode = 0)


## End(Not run)


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