addPlotObservations: Add plot observation records

View source: R/addPlotObservations.R

addPlotObservationsR Documentation

Add plot observation records

Description

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

Usage

addPlotObservations(
  target,
  x,
  mapping,
  missing.values = c(NA, ""),
  date.format = "%Y-%m-%d",
  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.

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).

  • projectTitle - Title of the project related to the plot observation (optional).

  • obsEndDate - Plot observation end date (optional; see date.format).

  • observationParty - Name of the party that undertook plot observation (optional).

  • plotUniqueIdentifier - A string used to identify the plot uniquely, preferably globally unique (optional).

missing.values

A character vector of values that should be considered as missing data (see details).

date.format

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

verbose

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

Details

Named elements in mapping beyond those used by this function will be ignored. Missing value policy:

  • Missing projectTitle, plotName, obsStartDate or obsEndDate 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 data refers to the parent plotName.

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(), addSiteCharacteristics(), addSiteObservations(), addStratumObservations(), addSurfaceCoverObservations(), addTaxonBySiteData()

Examples

# Load source data
data(mokihinui)

# Define mapping
mapping = list(projectTitle = "Project", plotName = "Plot", subPlotName = "Subplot",
               obsStartDate = "PlotObsStartDate", obsEndDate = "PlotObsStopDate")

# Create a new Veg-X document with projects, plots and plot observations (no data)
x = addPlotObservations(newVegX(), moki_site, mapping = mapping)

# Examine the result
showElementTable(x, "plot")
showElementTable(x, "plotObservation")

# The same but capturing unique identifiers from data source IDs (not used by the Veg-X package)

mapping = list(projectTitle = "Project", plotName = "Plot", subPlotName = "Subplot",
               obsStartDate = "PlotObsStartDate", obsEndDate = "PlotObsStopDate",
               plotUniqueIdentifier = "PlotID", plotObservationUniqueIdentifier = "PlotObsID")
x = addPlotObservations(newVegX(), moki_site, mapping = mapping)

showElementTable(x, "plot")
showElementTable(x, "plotObservation")

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