transformOrdinalScale.Rd
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.
transformOrdinalScale(
target,
method,
newMethod,
replaceValues = FALSE,
verbose = TRUE
)
The initial object of class VegX
to be modified.
An integer (index) or a name of an ordinal scale method.
An integer (index) or a name of a quantitative method existing in the initial object,
or an object of class VegXMethodDefinition
.
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.
A boolean flag to indicate console output of the data transformation process.
The modified object of class VegX
.
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
.
Other transform functions:
transformQuantitativeScale()
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)
#> 1 additional aggregate organism measurements found: Category.
#> Measurement method 'Recce cover scale' added for 'cover'.
#> Stratum definition method 'Recce strata' added.
#> 7 new stratum definitions added.
#> 5 plot(s) parsed, 5 new added.
#> 5 plot observation(s) parsed, 5 new added.
#> 148 organism names(s) parsed, 148 new added.
#> 148 organism identitie(s) parsed, 148 new added.
#> 33 stratum observation(s) parsed, 33 new added.
#> 582 record(s) parsed, 582 new aggregate organism observation(s) added.
#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)
#> 1 stratum measurement variables found.
#> Measurement method 'Recce cover scale' for 'cover' already included.
#> Stratum definition 'Recce strata' already included.
#> 5 plot(s) parsed, 0 new added.
#> 5 plot observation(s) parsed, 0 new added.
#> 35 record(s) parsed, 2 new stratum observation(s) added.
#> 7 measurement(s) with missing value(s) not added.
# Transform from "Recce cover scale" to "Plant cover/%"
percentScale = predefinedMeasurementMethod("Plant cover/%")
y = transformOrdinalScale(x, "Recce cover scale", percentScale)
#> Target method: 'Recce cover scale'
#> Number of attributes: 7
#> Number of quantifiable attributes with midpoints: 6
#> Limits of the new attribute: [0, 100]
#> Measurement method 'Plant cover/%' added.
#> 531 transformation(s) were applied on aggregate organism observations.
#> 28 transformation(s) were applied on stratum observations.