
Flatten SPHARM result list into a wide-format data frame
Source:R/spharm_utils.R
spharm_to_dataframe.RdConverts the per-specimen list returned by spharm_from_directions() or
spharm_from_meshes() into a single wide-format data frame, with one
row per specimen and one column per power-spectrum value and per
coefficient. Suitable for CSV export and downstream multivariate
analysis (PCA, UMAP, clustering) in R.
Arguments
- x
A list returned by
spharm_from_directions()orspharm_from_meshes().- include_coeffs
Logical. If
TRUE(default), include all flattened coefficients as columns namedcoeff_0001,coeff_0002, ... IfFALSE, return only the power spectrum (much smaller).
Value
A tibble with columns:
- ID
Specimen identifier.
- power_l0, power_l1, ..., power_lN
Raw power per spherical harmonic degree (N = lmax).
- coeff_0001, coeff_0002, ...
Flattened real-valued coefficients (only when
include_coeffs = TRUE).
Examples
if (FALSE) { # \dontrun{
result <- spharm_from_directions(my_aligned_data, lmax = 20)
# Full output (power + coefficients)
df_full <- spharm_to_dataframe(result)
# Power spectrum only (smaller, easier to inspect)
df_power <- spharm_to_dataframe(result, include_coeffs = FALSE)
write.csv(df_full, "spharm_results.csv", row.names = FALSE)
} # }