View source: R/transformQuantitativeScale.R
transformQuantitativeScale | R Documentation |
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 )
target |
The initial object of class |
method |
An integer (index) or a name of the original quantitative scale method. |
newMethod |
An integer (index) or a name of a quantitative method existing in the initial object,
or an object of class |
FUN |
A function used to transform numeric values. |
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. |
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
.
The modified object of class VegX
.
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) # Examine stratum heights showElementTable(x, "stratumObservation") # 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) # Examine new stratum heights showElementTable(y, "stratumObservation")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.