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

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.

Value

The modified object of class VegX.

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.

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

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"))
#>  Measurement method 'pH/0-14' added for 'a'.
#>  25 plot(s) parsed, 25 new plot(s) added.
#>  25 plot observation(s) parsed, 25 new plot observation(s) added.
#>  25 record(s) parsed, 25 new site observation(s) added.
# Examine results
summary(x)
#> ================================================================
#>                     Veg-X object (ver 2.0.0)                   
#> ----------------------------------------------------------------
#> 
#>    Projects: 0
#> 
#>    Plots: 25  [Parent plots: 5 Sub-plots: 20]
#> 
#>    Individual organisms: 0
#> 
#>    Organism names: 0
#> 
#>    Taxon concepts: 0
#> 
#>    Organism Identities: 0
#> 
#>    Vegetation strata: 0
#> 
#>    Surface types: 0
#> 
#>    Parties: 0
#> 
#>    Literature citations: 0
#> 
#>    Methods: 1
#>       1. pH/0-14 [pH / 1 quantitative atts.]
#> 
#>    Plot observations: 25  [in parent plots: 5 in sub-plots: 20]
#> 
#>    Individual organism observations: 0
#> 
#>    Aggregated organism observations: 0
#> 
#>    Stratum observations: 0
#> 
#>    Community observations: 0
#> 
#>    Site observations: 25
#> 
#>    Surface cover observations: 0
#> 
#> ================================================================
head(showElementTable(x, "siteObservation", subject=TRUE))
#>    plotName obsStartDate soil_1_method soil_1_subject soil_1_value
#> 1    LGM08r   2011-02-17       pH/0-14             pH            7
#> 2 LGM08r_1Q   2011-02-17       pH/0-14             pH            7
#> 3 LGM08r_2Q   2011-02-17       pH/0-14             pH            7
#> 4 LGM08r_3Q   2011-02-17       pH/0-14             pH            7
#> 5 LGM08r_4Q   2011-02-17       pH/0-14             pH            7
#> 6    LGM16l   2011-02-15       pH/0-14             pH            7