Adds individual organism observation records to a VegX object from a data frame where rows are individual observations.

addIndividualOrganismObservations(
  target,
  x,
  mapping,
  methods = list(),
  stratumDefinition = NULL,
  date.format = "%Y-%m-%d",
  missing.values = c(NA, "0", ""),
  verbose = TRUE
)

Arguments

target

The initial object of class VegX to be modified

x

A data frame where each row corresponds to one individual organism (e.g. a tree) observation. Columns can be varied.

mapping

A named list whose elements are strings that correspond to column names in x. Names of the list should be:

  • plotName - A string identifying the vegetation plot within the data set (required).

  • subPlotName - A string identifying a subplot of the plot given by plotName (optional).

  • obsStartDate - Plot observation start date (required; see date.format).

  • individualOrganismLabel - The string of a name, defined by the dataset author, and which does not follow nomenclatural codes.

  • organismName - The string of a name, defined by the dataset author, and which does not follow nomenclatural codes.

  • taxonName - The string of a taxon name (not necessarily including authority).

  • stratumName - A string used to identify a stratum (see stratumDefinition; optional).

  • diameterMeasurement - Individual organism (e.g. tree) diameter (optional).

  • heightMeasurement - Individual organism (e.g. tree) height (optional).

  • ... - User defined names used to map additional individual organism measurements (optional).

methods

A named list of objects of class VegXMethodDefinition indicating the definition of 'diameterMeasurement', 'heightMeasurement' and any additional individual organism measurement defined in mapping. Alternatively, methods can be specified using strings if predefined methods exist (see predefinedMeasurementMethod).

stratumDefinition

An object of class VegXStrataDefinition indicating the definition of strata.

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.

verbose

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

Value

The modified object of class VegX.

Details

The mapping should include either organismName or taxonName, but can include both of them if the source data set contains both taxon names and others that are not taxa. Missing value policy:

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

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

  • When both organismName and taxonName are missing the organism is assumed to be unidentified (i.e. no identity is added).

  • When individualOrganismLabel is missing the function creates a label for the organism.

  • When stratumName values are missing the individual organism observation is not assigned to any stratum.

  • Missing measurements (e.g. diameterMeasurement) are 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(mtfyffe)


# Define mapping
mapping = list(plotName = "Plot", subPlotName = "Subplot", obsStartDate = "PlotObsStartDate",
               taxonName = "NVSSpeciesName", individualOrganismLabel = "Identifier",
               diameterMeasurement = "Diameter")


# Create new Veg-X document with individual organism observations
x = addIndividualOrganismObservations(newVegX(), mtfyffe_dia, mapping,
                                      methods = list(diameterMeasurement = "DBH/cm"),
                                      missing.values = c(NA, "(Unknown)", "0",""))
#>  Measurement method 'DBH/cm' added for 'diameterMeasurement'.
#>  67 plot(s) parsed, 67 new added.
#>  117 plot observation(s) parsed, 117 new added.
#>  29 organism names(s) parsed, 29 new added.
#>  0 taxon concept(s) parsed, 0 new added.
#>  29 organism identitie(s) parsed, 29 new added.
#>  725 individual organism(s) parsed, 725 new added.
#>  1082 record(s) parsed, 1082 new individual organism observation(s) added.
#>  105 individual organism observation(s) with missing diameter value(s) not added.

# Inspect the result
head(showElementTable(x, "individualOrganismObservation"))
#>   plotName obsStartDate individualOrganismLabel organismIdentityName
#> 1   17 3_L   1980-02-07                    5167      Coprosma lucida
#> 2    6 4_I   1980-02-07                    7778      Rubus cissoides
#> 3    6 4_D   1980-02-07                    7701 Pseudopanax arboreus
#> 4   17 3_K   1980-02-07                    5178  Fuchsia excorticata
#> 5    6 4_D   1980-02-07                    7703 Coprosma grandifolia
#> 6   17 3_C   1980-02-07                    5114  Fuchsia excorticata
#>   diameter_method diameter_value
#> 1          DBH/cm            7.9
#> 2          DBH/cm            2.9
#> 3          DBH/cm            4.6
#> 4          DBH/cm           14.3
#> 5          DBH/cm            3.5
#> 6          DBH/cm           17.0



# Second example without individual labels
data(mokihinui)
mapping = list(plotName = "Plot", subPlotName = "Subplot", obsStartDate = "PlotObsStartDate",
               taxonName = "NVSSpeciesName", diameterMeasurement = "Diameter")
x = addIndividualOrganismObservations(newVegX(), moki_dia, mapping = mapping,
                                      methods = list(diameterMeasurement = "DBH/cm"),
                                      missing.values = c(NA, "(Unknown)", "0",""))
#>  Measurement method 'DBH/cm' added for 'diameterMeasurement'.
#>  23 plot(s) parsed, 23 new added.
#>  18 plot observation(s) parsed, 18 new added.
#>  28 organism names(s) parsed, 28 new added.
#>  0 taxon concept(s) parsed, 0 new added.
#>  28 organism identitie(s) parsed, 28 new added.
#>  0 individual organism(s) parsed, 643 new added.
#>  643 record(s) parsed, 643 new individual organism observation(s) added.
head(showElementTable(x, "individualOrganismObservation"))
#>    plotName obsStartDate individualOrganismLabel organismIdentityName
#> 1 LGM38h_1Q   2011-02-20                    ind1  Weinmannia racemosa
#> 2 LGM38h_1Q   2011-02-20                    ind2 Coprosma grandifolia
#> 3 LGM38h_1Q   2011-02-20                    ind3      Cyathea smithii
#> 4 LGM38h_1Q   2011-02-20                    ind4 Coprosma grandifolia
#> 5 LGM38h_1Q   2011-02-20                    ind5  Weinmannia racemosa
#> 6 LGM38h_2Q   2011-02-20                    ind1      Cyathea smithii
#>   diameter_method diameter_value
#> 1          DBH/cm           10.6
#> 2          DBH/cm            4.0
#> 3          DBH/cm           11.3
#> 4          DBH/cm            6.1
#> 5          DBH/cm            6.5
#> 6          DBH/cm           13.6