transformOrdinalScale: Transform ordinal scale

View source: R/transformOrdinalScale.R

transformOrdinalScaleR Documentation

Transform ordinal scale

Description

Transforms all the values in a VegX object made using an ordinal scale into a quantitative scale appropriate for the midpoint values of the ordinal classes.

Usage

transformOrdinalScale(
  target,
  method,
  newMethod,
  replaceValues = FALSE,
  verbose = TRUE
)

Arguments

target

The initial object of class VegX to be modified.

method

An integer (index) or a name of an ordinal scale method.

newMethod

An integer (index) or a name of a quantitative method existing in the initial object, or an object of class VegXMethodDefinition.

replaceValues

A boolean flag to indicate that values in the new scale should replace the old ones, instead of defining new measurements. For some measurements transformations will not be possible if replacement is not forced using this flag.

verbose

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

Details

The function will normally create new measurements without destroying the original ones, unless replacement is forced by setting replaceValues = TRUE. Veg-X only allows a single measurement per observations of some kinds:

  • "diameterMeasurement" and "heightMeasurement" of indvidual organism observations.

  • "heightMeasurement" of aggregate organism observations.

  • "lowerLimitMeasurement" and "upperLimitMeasurement" of stratum observations.

In these cases, scale transformations are not possible if replaceValues = FALSE.

Value

The modified object of class VegX.

See Also

Other transform functions: transformQuantitativeScale()

Examples

data(mokihinui)

# Create Veg-X document with aggregate organism observations 
# with ordinal cover scale
taxmapping = list(plotName = "Plot", obsStartDate = "PlotObsStartDate", 
              taxonName = "NVSSpeciesName",
              stratumName = "Tier", cover = "Category")
coverscale = defineOrdinalScaleMethod(name = "Recce cover scale",
               description = "Recce recording method by Hurst/Allen",
               subject = "plant cover",
               citation = "Hurst, JM and Allen, RB. (2007) 
                     The Recce method for describing New Zealand vegetation – 
                     Field protocols. Landcare Research, Lincoln.",
               codes = c("P","1","2","3", "4", "5", "6"),
               quantifiableCodes = c("1","2","3", "4", "5", "6"),
               breaks = c(0, 1, 5, 25, 50, 75, 100),
               midPoints = c(0.05, 0.5, 15, 37.5, 62.5, 87.5),
               definitions = c("Presence", "<1%", "1-5%","6-25%", 
                               "26-50%", "51-75%", "76-100%"))
strataDef = defineMixedStrata(name = "Recce strata",
               description = "Standard Recce stratum definition",
               citation = "Hurst, JM and Allen, RB. (2007) 
                    The Recce method for describing New Zealand vegetation – 
                    Field protocols. Landcare Research, Lincoln.",
               heightStrataBreaks = c(0, 0.3,2.0,5, 12, 25, 50),
               heightStrataNames = paste0("Tier ",1:6),
               categoryStrataNames = "Tier 7",
               categoryStrataDefinition = "Epiphytes")
x = addAggregateOrganismObservations(newVegX(), moki_tcv,
               mapping = taxmapping,
               methods = c(cover=coverscale),
               stratumDefinition = strataDef)

#Add stratum observations with ordinal cover scale
mapping = list(plotName = "Plot", obsStartDate = "PlotObsStartDate", 
               stratumName = "Tier",
               cover = "CoverClass")

x = addStratumObservations(x, moki_str,
                        mapping = mapping,
                        methods = list(cover=coverscale),
                        stratumDefinition = strataDef)


# Transform from "Recce cover scale" to "Plant cover/%"
percentScale = predefinedMeasurementMethod("Plant cover/%")
y = transformOrdinalScale(x, "Recce cover scale", percentScale)


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