View source: R/transformCharacter.R
transformCharacter | R Documentation |
This function transforms morphological characters by applying another function passed in the argument.
transformCharacter(object, character, FUN, newName = NULL)
object |
an object of class |
character |
a morphological character that should be transformed. |
FUN |
the transforming function to be applied to character. |
newName |
a name to rename the original character. If |
Transformation is applied to characters to improve their distribution (to become normally distributed or at least to achieve lesser deviation from normality). The FUN
argument takes any function, able to accept as input any value of the character specified by character
argument.
Note that, when using a log transformation, a constant should be added to all values to make them all positive before transformation (if there are zero values in the data), because the argument of the logarithm can be only positive numbers. The arcsine transformation is applicable for proportions and percentages (for values ranging from 0 to 1).
an object of class morphodata
with the following elements:
ID |
IDs of each row of |
Population |
population membership of each row of |
Taxon |
taxon membership of each row of |
data |
|
data(centaurea)
# For a right-skewed (positive) distribution can be used:
# Logarithmic transformation
cTransf = transformCharacter(centaurea, character = "SF", FUN = function(x) log(x+1))
cTransf = transformCharacter(centaurea, character = "SF", FUN = function(x) log10(x+1))
# Square root transformation
cTransf = transformCharacter(centaurea, character = "SF", FUN = function(x) sqrt(x))
# Cube root transformation
cTransf = transformCharacter(centaurea, character = "SF", FUN = function(x) x^(1/3))
# Arcsine transformation
cTransf = transformCharacter(centaurea, character = "SF", FUN = function(x) asin(sqrt(x)))
# For a left-skewed (negative) distribution can be used:
# Logarithmic transformation
cTransf = transformCharacter(centaurea, character="SF", FUN=function(x) log((max(x)+1)-x))
cTransf = transformCharacter(centaurea, character="SF", FUN=function(x) log10((max(x)+1)-x))
# Square root transformation
cTransf = transformCharacter(centaurea, character="SF", FUN=function(x) sqrt((max(x)+1)-x))
# Cube root transformation
cTransf = transformCharacter(centaurea, character="SF", FUN=function(x) ((max(x)+1)-x)^(1/3))
# Arcsine transformation
cTransf = transformCharacter(centaurea, character="SF", FUN=function(x) asin(sqrt((max(x))-x)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.