Learn R Programming

calba (version 0.1.2)

neigh_ba: Neighborhood summaries for basal area and counts

Description

Provide a tidy summary of pairwise neighborhood basal area and counts, optionally including decay results for a vector of decay parameters.

Usage

neigh_ba(
  sp,
  gx,
  gy,
  ba,
  r,
  mu_values = NULL,
  dist_weighted = FALSE,
  exponential_normal = FALSE,
  edge_correction = c("none", "safe"),
  bounds = NULL
)

Value

A list with * `summary`: data frame with `tree_id`, `species`, `con_ba`, `total_ba`, `con_count`, `total_count`. * `decay`: (`NULL` or) long data frame with `tree_id`, `species`, `mu`, `con_ba`, `total_ba`.

The `summary` component also includes derived columns: `prop_con_ba`, `het_ba`, `het_count`, and `competition_index`.

Arguments

sp

A character or factor vector of species names.

gx

Numeric x-coordinates of each tree.

gy

Numeric y-coordinates of each tree.

ba

Numeric basal area of each tree.

r

Positive numeric radius within which neighbors are considered.

mu_values

Optional numeric vector of decay parameters. When `NULL`, the decay table is omitted.

dist_weighted

Logical flag passed to `ba_simple` to use a simple `ba / dist` weighting when `TRUE`.

exponential_normal

Logical passed to `ba_decay` to select the exponential-normal kernel.

edge_correction

Character; see `ba_simple()` for the `"safe"` option that skips edge focal trees.

bounds

Optional numeric vector `c(xmin, xmax, ymin, ymax)` giving the plot extent. When `NULL`, the range of `gx`/`gy` is used; supply bounds if your data do not span the full plot.

Examples

Run this code
sample_data <- data.frame(
  latin = sample(letters[1:4], 10, replace = TRUE),
  gx = runif(10, 0, 10),
  gy = runif(10, 0, 10),
  ba = runif(10, 10, 30)
)
neigh_ba(
  sp = sample_data$latin,
  gx = sample_data$gx,
  gy = sample_data$gy,
  ba = sample_data$ba,
  r = 3,
  mu_values = c(1, 3)
)

Run the code above in your browser using DataLab