Calculate the centroid size (CS): the square root of the sum of squared distances from each point to the centroid.
Value
If
xis a single matrix: returns a numeric scalarIf
xis a list: returns a numeric vectorIf
xis a tibble: returns a numeric vector extracted from coo column
Details
Centroid size is a common size measure in geometric morphometrics. It is scale-independent and used for allometric correction.
For tibbles, this function extracts values without modifying the tibble.
Use within mutate() to add as a column: mutate(df, cs = get_centroid_size(coo))
Examples
get_centroid_size(shapes$cat)
#> [1] 847.9577
get_centroid_size(shapes)
#> $cat
#> [1] 847.9577
#>
#> $dog
#> [1] 950.7276
#>
#> $heart
#> [1] 978.0189
#>
#> $leaf2
#> [1] 814.8906
#>
# Extract from tibble
sizes <- get_centroid_size(bot)
# Add to tibble
bot$centsize <- get_centroid_size(bot)
