Joins species and environmental data by matching observations that are close in time and space, enabling correlation analysis between abundance and environmental variables.
prep_splot(
df_sp,
df_env,
env_stat,
method = "nearest_time",
max_hours_diff = 72,
max_meters_diff = 1000
)dbplyr lazy table or data.frame with species data
dbplyr lazy table or data.frame with environmental data
Character string specifying aggregation function (e.g., "mean", "median")
Numeric maximum time difference (in hours) for matching observations (default: 72)
Numeric maximum spatial distance (in meters) for matching observations (default: 1000)
data.frame with matched species-environment observations
This function performs a fuzzy join based on temporal proximity using
fuzzyjoin::difference_inner_join(). For each species observation,
the closest environmental measurement (within max_hours_diff) is
selected. Data is collected from database before joining.
if (FALSE) { # \dontrun{
df_sp <- get_sp("Anchovy (Engraulis mordax)", qtr = 1:4, date_range = c("2000-01-01", "2020-12-31"))
df_env <- get_env("t_deg_c", qtr = 1:4, date_range = c("2000-01-01", "2020-12-31"), min_depth = 0, max_depth = 100)
df_splot <- prep_splot(df_sp, df_env, env_stat = "mean")
} # }