
Assemble community matrices for invasion-fitness workflows
Source:R/assemble_matrices.R
assemble_matrices.Rdassemble_matrices() creates the standard inputs used throughout the
invasion-fitness pipeline from either a single “long” table or a set of
already-formed tables. It returns aligned objects:
site_df(site × x,y),env_df(site × environment; numeric matrix),comm_res(site × resident abundances; numeric matrix),pa_res(site × resident presence/absence; integer matrix),traits_res(resident × traits; data frame, keeps mixed types).
Usage
assemble_matrices(
long_df = NULL,
site_df = NULL,
env_df = NULL,
comm_res = NULL,
traits_res = NULL,
comm_long = c("auto", "long", "wide"),
site_col = "site",
x_col = "x",
y_col = "y",
species_col = "species",
count_col = "count",
env_cols = NULL,
env_prefix = "^env",
trait_cols = NULL,
trait_prefix = "^trait",
drop_empty_sites = TRUE,
drop_empty_species = TRUE,
return_diversity = TRUE,
make_plots = FALSE
)Arguments
- long_df
Optional long data frame with at least
site,x,y,species,count.- site_df
Optional data frame with columns
site,x,y(used whenlong_dfisNULL).- env_df
Optional site × environment numeric data frame/matrix (row names must be site IDs; used when
long_dfisNULL).- comm_res
Optional site × resident numeric matrix/data frame (wide) or a long table with
site,species,count(seecomm_long).- traits_res
Optional resident × traits data frame (row names = species).
- comm_long
How to interpret a separately supplied
comm_res: one ofc("auto","long","wide");"auto"detects a long table and pivots.- site_col, x_col, y_col, species_col, count_col
Column names to use when building from
long_df. Defaults:"site","x","y","species","count".- env_cols, env_prefix, trait_cols, trait_prefix, drop_empty_sites,
drop_empty_species,return_diversity,make_plots See details in original docs.