Learn R Programming

calba (version 0.1.2)

neigh_multi_r: Neighborhood metrics across multiple radii

Description

Compute basal area sums and counts for each tree across multiple radii in one pass.

Usage

neigh_multi_r(
  sp,
  gx,
  gy,
  ba,
  r_values,
  dist_weighted = FALSE,
  edge_correction = c("none", "safe"),
  bounds = NULL
)

Value

A tidy tibble with `tree_id`, `species`, `radius`, `con_ba`, `total_ba`, `con_count`, `total_count`, `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 the trees.

gy

Numeric y-coordinates of the trees.

ba

Numeric basal area for each tree.

r_values

Numeric vector of radii to evaluate.

dist_weighted

Logical flag to use `ba / dist` weighting within each radius.

edge_correction

Character; see `ba_simple()` for the `"safe"` option.

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_multi_r(
  sp = sample_data$latin,
  gx = sample_data$gx,
  gy = sample_data$gy,
  ba = sample_data$ba,
  r_values = c(3, 5)
)

Run the code above in your browser using DataLab