ecometric_space {commecometrics}R Documentation

Plot ecometric space for quantitative environmental variables

Description

Visualizes the ecometric space for quantitative environmental variables based on the output from ecometric_model().

Usage

ecometric_space(
  model_out,
  env_name = "env_var",
  fossil_data = NULL,
  fossil_color = "#000000",
  modern_color = "#bc4749",
  palette = c("#bc6c25", "#fefae0", "#606c38"),
  x_label = "Summary metric 1",
  y_label = "Summary metric 2"
)

Arguments

model_out

Output from ecometric_model(), containing environmental estimates in trait space.

env_name

Name to display for the environmental variable (used in the legend title).

fossil_data

Optional. Output from reconstruct_env().

fossil_color

Outline color for fossil data bins (default: "#000000").

modern_color

Outline color for modern data bins (default: "#bc4749").

palette

Vector of colors to use for the gradient scale representing environmental values.

x_label

Label for the x-axis in the output plots (default: "Summary metric 1").

y_label

Label for the y-axis in the output plots (default: "Summary metric 2").

Value

A ggplot2 object visualizing the ecometric trait-environment surface.

Examples


# Load internal data
data("geoPoints", package = "commecometrics")
data("traits", package = "commecometrics")
data("spRanges", package = "commecometrics")
data("fossils", package = "commecometrics")

# Summarize trait values at sampling points
traitsByPoint <- summarize_traits_by_point(
  points_df = geoPoints,
  trait_df = traits,
  species_polygons = spRanges,
  trait_column = "RBL",
  species_name_col = "sci_name",
  continent = FALSE,
  parallel = FALSE
)

# Run ecometric model
ecoModel <- ecometric_model(
  points_df = traitsByPoint$points,
  env_var = "precip",
  transform_fun = function(x) log(x + 1),
  inv_transform_fun = function(x) exp(x) - 1,
  min_species = 3
)

# Reconstruct environments for fossil sites
recon <- reconstruct_env(
  fossildata = fossils,
  model_out = ecoModel,
  match_nearest = TRUE,
  fossil_lon = "Long",
  fossil_lat = "Lat",
  modern_id = "ID",
  modern_lon = "Longitude",
  modern_lat = "Latitude"
)

# Plot the ecometric trait–environment space
ecometricPlot <- ecometric_space(
  model_out = ecoModel,
  env_name = "Precipitation (log mm)",
  fossil_data = recon
)

# Display plot
print(ecometricPlot)


[Package commecometrics version 1.0.0 Index]