addSiteObservations: Add site observation records

View source: R/addSiteObservations.R

addSiteObservationsR Documentation

Add site observation records

Description

Adds site observation records to a VegX object from a data table where rows are plot observations.

Usage

addSiteObservations(
  target,
  x,
  plotObservationMapping,
  soilMeasurementMapping = list(),
  climateMeasurementMapping = list(),
  waterBodyMeasurementMapping = list(),
  soilMeasurementMethods = list(),
  climateMeasurementMethods = list(),
  waterBodyMeasurementMethods = list(),
  date.format = "%Y-%m-%d",
  missing.values = c(NA, ""),
  fill.methods = FALSE,
  verbose = TRUE
)

Arguments

target

The initial object of class VegX to be modified

x

A data frame where each row corresponds to one plot observation. Columns can be varied.

plotObservationMapping

A list with element names 'plotName', 'obsStartDate', used to specify the mapping of data columns (specified using strings for column names) onto these variables. Additional optional mappings are: 'subPlotName'.

soilMeasurementMapping

A named list used to specify the mapping of data columns to soil variables (e.g. a = "pH" to map variable "pH" of the data frame). List names should be the same as in soilMeasurementMethods.

climateMeasurementMapping

A named list used to specify the mapping of data columns to climate variables. List names should be the same as in climateMeasurementMethods.

waterBodyMeasurementMapping

A named list used to specify the mapping of data columns to water body variables. List names should be the same as in waterBodyMeasurementMethods.

soilMeasurementMethods

A named list of objects of class VegXMethodDefinition with the measurement method for each of the element names stated in soilMeasurementMapping (e.g. list(a = pHmeth) to specify the use of method 'pHmeth' for soil1). Alternatively, methods can be specified using strings if predefined methods exist (e.g. list(a = "pH/0-14") to use the predefined method "pH/0-14"), see predefinedMeasurementMethod.

climateMeasurementMethods

A named list of objects of class VegXMethodDefinition with the measurement method for each of the element names stated in climateMeasurementMapping. List names should be the same as climate subject measurement variables. Alternatively, methods can be specified using strings if predefined methods exist, see predefinedMeasurementMethod.

waterBodyMeasurementMethods

A named list of objects of class VegXMethodDefinition with the measurement method for each of the element names stated in waterBodyMeasurementMapping. List names should be the same as water body subject measurement variables. Alternatively, methods can be specified using strings if predefined methods exist, see predefinedMeasurementMethod.

date.format

A character string specifying the input format of dates (see as.Date).

missing.values

A character vector of values that should be considered as missing observations/measurements.

fill.methods

A flag to indicate that missing methods should be filled with dummy ones. This allows easily storing any environmental data, but without appropriate metadata.

verbose

A boolean flag to indicate console output of the data integration process.

Details

Unlike in other functions, here the element names of mappings are only used to find the corresponding method. The measured subject (e.g. pH, salinity or mean annual temperature) is taken from the method definition. There is one exception to this rule: users can use fill.methods = TRUE to skip defining methods for all environmental variables. In this case, the function will define dummy measurement methods, taking the element name of the mapping list as subject. For example, if soilMeasurementMapping = list(pHvar = "pH") and no method is provided for pHvar in soilMeasurementMethods, the function will create a dummy measurement method called 'pHvar'. Although this possibility is given to ease import, users are encouraged to define site measurement methods or to use predefined ones. When defining measurement methods, users should preferably name subjects using the same strings as in predefined methods, because this facilitates merging datasets where the same entities have been measured. Please contact Veg-X developers to ask for additional predefined measurement methods if you think they are rellevant for exchanging vegetation plot data.

Missing value policy:

  • Missing 'plotName' or 'obsStartDate' values are interpreted as if the previous non-missing value has to be used to define plot observation.

  • Missing 'subPlotName' values are interpreted in that observation refers to the parent plotName.

  • Missing measurements are simply not added to the Veg-X document.

Value

The modified object of class VegX.

References

Wiser SK, Spencer N, De Caceres M, Kleikamp M, Boyle B & Peet RK (2011). Veg-X - an exchange standard for plot-based vegetation data

See Also

Other add functions: addAggregateOrganismObservations(), addCommunityObservations(), addIndividualOrganismObservations(), addPlotGeometries(), addPlotLocations(), addPlotObservations(), addSiteCharacteristics(), addStratumObservations(), addSurfaceCoverObservations(), addTaxonBySiteData()

Examples

# Load source data
data(mokihinui)

# Define mapping
mapping = list(plotName = "Plot", subPlotName = "Subplot",
               obsStartDate = "PlotObsStartDate")

# Create new Veg-X document with site observations
# Uses predefined measurement method "pH/0-14"
x = addSiteObservations(newVegX(), moki_site,
                        plotObservationMapping = mapping,
                        soilMeasurementMapping = list(a = "pH") ,
                        soilMeasurementMethods = list(a = "pH/0-14"))
# Examine results
summary(x)
head(showElementTable(x, "siteObservation", subject=TRUE))


miquelcaceres/VegX documentation built on Sept. 18, 2022, 7:04 p.m.