transformQuantitativeScale.Rd
Transforms all the values in a VegX object made using a quantitative scale into another quantitative scale following a given transformation function.
transformQuantitativeScale(
target,
method,
newMethod,
FUN,
replaceValues = FALSE,
verbose = TRUE
)
The initial object of class VegX
to be modified.
An integer (index) or a name of the original quantitative scale method.
An integer (index) or a name of a quantitative method existing in the initial object,
or an object of class VegXMethodDefinition
.
A function used to transform numeric values.
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:
transformOrdinalScale()
data(mokihinui)
# Create initial Veg-X document with stratum heights in meters
mapping = list(plotName = "Plot", obsStartDate = "PlotObsStartDate",
stratumName = "Tier",
lowerLimitMeasurement = "TierLower",
upperLimitMeasurement = "TierUpper")
heightMethod1 = predefinedMeasurementMethod("Stratum height/m")
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 = addStratumObservations(newVegX(), moki_str,
mapping = mapping,
methods = list(lowerLimitMeasurement = heightMethod1,
upperLimitMeasurement = heightMethod1),
stratumDefinition = strataDef)
#> 0 stratum measurement variables found.
#> Measurement method 'Stratum height/m' added for 'lowerLimitMeasurement'.
#> Measurement method 'Stratum height/m' for 'upperLimitMeasurement' already included.
#> 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.
#> 35 record(s) parsed, 35 new stratum observation(s) added.
# Examine stratum heights
showElementTable(x, "stratumObservation")
#> plotName obsStartDate stratumName lowerLimit_method lowerLimit_value
#> 1 LGM38h 2011-02-20 Tier 1 Stratum height/m 25.0
#> 2 LGM38h 2011-02-20 Tier 2 Stratum height/m 12.0
#> 3 LGM38h 2011-02-20 Tier 3 Stratum height/m 5.0
#> 4 LGM38h 2011-02-20 Tier 4 Stratum height/m 2.0
#> 5 LGM38h 2011-02-20 Tier 5 Stratum height/m 0.3
#> 6 LGM45h 2011-02-11 Tier 1 Stratum height/m 25.0
#> 7 LGM45h 2011-02-11 Tier 2 Stratum height/m 12.0
#> 8 LGM45h 2011-02-11 Tier 3 Stratum height/m 5.0
#> 9 LGM45h 2011-02-11 Tier 4 Stratum height/m 2.0
#> 10 LGM45h 2011-02-11 Tier 5 Stratum height/m 0.3
#> 11 LGM45h 2011-02-11 Tier 6 Stratum height/m 0.0
#> 12 LGM45h 2011-02-11 Tier 7 Stratum height/m 0.0
#> 13 LGM38h 2011-02-20 Tier 6 Stratum height/m 0.0
#> 14 LGM38h 2011-02-20 Tier 7 Stratum height/m 0.0
#> 15 LGM08r 2011-02-17 Tier 1 Stratum height/m 25.0
#> 16 LGM08r 2011-02-17 Tier 2 Stratum height/m 12.0
#> 17 LGM08r 2011-02-17 Tier 3 Stratum height/m 5.0
#> 18 LGM08r 2011-02-17 Tier 4 Stratum height/m 2.0
#> 19 LGM08r 2011-02-17 Tier 5 Stratum height/m 0.3
#> 20 LGM08r 2011-02-17 Tier 6 Stratum height/m 0.0
#> 21 LGM08r 2011-02-17 Tier 7 Stratum height/m 0.0
#> 22 LGM43h 2011-02-13 Tier 1 Stratum height/m 25.0
#> 23 LGM43h 2011-02-13 Tier 2 Stratum height/m 12.0
#> 24 LGM43h 2011-02-13 Tier 3 Stratum height/m 5.0
#> 25 LGM43h 2011-02-13 Tier 4 Stratum height/m 2.0
#> 26 LGM43h 2011-02-13 Tier 5 Stratum height/m 0.3
#> 27 LGM43h 2011-02-13 Tier 6 Stratum height/m 0.0
#> 28 LGM43h 2011-02-13 Tier 7 Stratum height/m 0.0
#> 29 LGM16l 2011-02-15 Tier 1 Stratum height/m 25.0
#> 30 LGM16l 2011-02-15 Tier 2 Stratum height/m 12.0
#> 31 LGM16l 2011-02-15 Tier 3 Stratum height/m 5.0
#> 32 LGM16l 2011-02-15 Tier 4 Stratum height/m 2.0
#> 33 LGM16l 2011-02-15 Tier 5 Stratum height/m 0.3
#> 34 LGM16l 2011-02-15 Tier 6 Stratum height/m 0.0
#> 35 LGM16l 2011-02-15 Tier 7 Stratum height/m 0.0
#> upperLimit_method upperLimit_value
#> 1 Stratum height/m 50.0
#> 2 Stratum height/m 25.0
#> 3 Stratum height/m 12.0
#> 4 Stratum height/m 5.0
#> 5 Stratum height/m 2.0
#> 6 Stratum height/m 50.0
#> 7 Stratum height/m 25.0
#> 8 Stratum height/m 12.0
#> 9 Stratum height/m 5.0
#> 10 Stratum height/m 2.0
#> 11 Stratum height/m 0.3
#> 12 Stratum height/m 0.0
#> 13 Stratum height/m 0.3
#> 14 Stratum height/m 0.0
#> 15 Stratum height/m 50.0
#> 16 Stratum height/m 25.0
#> 17 Stratum height/m 12.0
#> 18 Stratum height/m 5.0
#> 19 Stratum height/m 2.0
#> 20 Stratum height/m 0.3
#> 21 Stratum height/m 0.0
#> 22 Stratum height/m 50.0
#> 23 Stratum height/m 25.0
#> 24 Stratum height/m 12.0
#> 25 Stratum height/m 5.0
#> 26 Stratum height/m 2.0
#> 27 Stratum height/m 0.3
#> 28 Stratum height/m 0.0
#> 29 Stratum height/m 50.0
#> 30 Stratum height/m 25.0
#> 31 Stratum height/m 12.0
#> 32 Stratum height/m 5.0
#> 33 Stratum height/m 2.0
#> 34 Stratum height/m 0.3
#> 35 Stratum height/m 0.0
# Transform stratum heights from m to cm by multiplying values by 10
# ('replaceValues' needs to be set to TRUE to force replacement)
heightMethod2 = predefinedMeasurementMethod("Stratum height/cm")
y = transformQuantitativeScale(x, "Stratum height/m", heightMethod2,
function(x){return(x*10)},
replaceValues = TRUE)
#> Target method: 'Stratum height/m'
#> Number of quantitative attributes: 1
#> Measurement method 'Stratum height/cm' added.
#> 70 transformation(s) were applied on stratum observations.
# Examine new stratum heights
showElementTable(y, "stratumObservation")
#> plotName obsStartDate stratumName lowerLimit_method lowerLimit_value
#> 1 LGM38h 2011-02-20 Tier 1 Stratum height/cm 250
#> 2 LGM38h 2011-02-20 Tier 2 Stratum height/cm 120
#> 3 LGM38h 2011-02-20 Tier 3 Stratum height/cm 50
#> 4 LGM38h 2011-02-20 Tier 4 Stratum height/cm 20
#> 5 LGM38h 2011-02-20 Tier 5 Stratum height/cm 3
#> 6 LGM45h 2011-02-11 Tier 1 Stratum height/cm 250
#> 7 LGM45h 2011-02-11 Tier 2 Stratum height/cm 120
#> 8 LGM45h 2011-02-11 Tier 3 Stratum height/cm 50
#> 9 LGM45h 2011-02-11 Tier 4 Stratum height/cm 20
#> 10 LGM45h 2011-02-11 Tier 5 Stratum height/cm 3
#> 11 LGM45h 2011-02-11 Tier 6 Stratum height/cm 0
#> 12 LGM45h 2011-02-11 Tier 7 Stratum height/cm 0
#> 13 LGM38h 2011-02-20 Tier 6 Stratum height/cm 0
#> 14 LGM38h 2011-02-20 Tier 7 Stratum height/cm 0
#> 15 LGM08r 2011-02-17 Tier 1 Stratum height/cm 250
#> 16 LGM08r 2011-02-17 Tier 2 Stratum height/cm 120
#> 17 LGM08r 2011-02-17 Tier 3 Stratum height/cm 50
#> 18 LGM08r 2011-02-17 Tier 4 Stratum height/cm 20
#> 19 LGM08r 2011-02-17 Tier 5 Stratum height/cm 3
#> 20 LGM08r 2011-02-17 Tier 6 Stratum height/cm 0
#> 21 LGM08r 2011-02-17 Tier 7 Stratum height/cm 0
#> 22 LGM43h 2011-02-13 Tier 1 Stratum height/cm 250
#> 23 LGM43h 2011-02-13 Tier 2 Stratum height/cm 120
#> 24 LGM43h 2011-02-13 Tier 3 Stratum height/cm 50
#> 25 LGM43h 2011-02-13 Tier 4 Stratum height/cm 20
#> 26 LGM43h 2011-02-13 Tier 5 Stratum height/cm 3
#> 27 LGM43h 2011-02-13 Tier 6 Stratum height/cm 0
#> 28 LGM43h 2011-02-13 Tier 7 Stratum height/cm 0
#> 29 LGM16l 2011-02-15 Tier 1 Stratum height/cm 250
#> 30 LGM16l 2011-02-15 Tier 2 Stratum height/cm 120
#> 31 LGM16l 2011-02-15 Tier 3 Stratum height/cm 50
#> 32 LGM16l 2011-02-15 Tier 4 Stratum height/cm 20
#> 33 LGM16l 2011-02-15 Tier 5 Stratum height/cm 3
#> 34 LGM16l 2011-02-15 Tier 6 Stratum height/cm 0
#> 35 LGM16l 2011-02-15 Tier 7 Stratum height/cm 0
#> upperLimit_method upperLimit_value
#> 1 Stratum height/cm 500
#> 2 Stratum height/cm 250
#> 3 Stratum height/cm 120
#> 4 Stratum height/cm 50
#> 5 Stratum height/cm 20
#> 6 Stratum height/cm 500
#> 7 Stratum height/cm 250
#> 8 Stratum height/cm 120
#> 9 Stratum height/cm 50
#> 10 Stratum height/cm 20
#> 11 Stratum height/cm 3
#> 12 Stratum height/cm 0
#> 13 Stratum height/cm 3
#> 14 Stratum height/cm 0
#> 15 Stratum height/cm 500
#> 16 Stratum height/cm 250
#> 17 Stratum height/cm 120
#> 18 Stratum height/cm 50
#> 19 Stratum height/cm 20
#> 20 Stratum height/cm 3
#> 21 Stratum height/cm 0
#> 22 Stratum height/cm 500
#> 23 Stratum height/cm 250
#> 24 Stratum height/cm 120
#> 25 Stratum height/cm 50
#> 26 Stratum height/cm 20
#> 27 Stratum height/cm 3
#> 28 Stratum height/cm 0
#> 29 Stratum height/cm 500
#> 30 Stratum height/cm 250
#> 31 Stratum height/cm 120
#> 32 Stratum height/cm 50
#> 33 Stratum height/cm 20
#> 34 Stratum height/cm 3
#> 35 Stratum height/cm 0