ensureProtectedData: Function to check whether the data will over write protected...

Description Usage Arguments Value

Description

Certain data in the Statistical Working System should not be over written by algorithms. Namely, official and semi-official values. This function takes the data to be saved in the arguement and pulls the exact same set of data from the data base, then checks whether the matching set contains official or semi official values.

Usage

1
2
3
4
5
6
7
ensureProtectedData(data, domain = "agriculture", dataset = "aproduction",
  areaVar = "geographicAreaM49", itemVar = "measuredItemCPC",
  elementVar = "measuredElement", yearVar = "timePointYears",
  flagObservationVar = "flagObservationStatus",
  flagMethodVar = "flagMethod", flagTable = flagValidTable,
  returnData = TRUE, normalised = TRUE,
  denormalisedKey = "measuredElement", getInvalidData = FALSE)

Arguments

data

The data.table object containing data to be saved back to the database. The current implementation only accepts data in the normalised form.

domain

The domain name in the SWS where the data will be saved.

dataset

The dataset name in the SWS where the data will be saved.

areaVar

The column name corresponding to the geographic area.

itemVar

The column name corresponding to the commodity item.

elementVar

The column name corresponding to the measured element.

yearVar

The column name corresponding to the year.

flagObservationVar

The column name corresponding to the observation status flag.

flagMethodVar

The column name corresponding to the method flag.

flagTable

The flag table containing the validity of the flags. see datafaoswsFlag::flagValidTable for an example.

returnData

logical, whether the data should be returned.

normalised

logical, whether the data is normalised

denormalisedKey

optional, only required if the input data is not normalised.It is the name of the key that denormalises the data.

getInvalidData

logical, this will skip the test and extract the data that is invalid.

Value

If getInvalidData is FALSE, then the data is returned when the test is cleared, otherwise an error. If getInvalidData is TRUE, then the subset of the data that is invalid is returned.


SWS-Methodology/faoswsEnsure documentation built on May 9, 2019, 11:47 a.m.