Learn R Programming

calba (version 0.1.2)

count_con: Count Conspecific Trees

Description

This function counts the number of conspecific trees within a given radius for each focal tree.

Usage

count_con(sp, gx, gy, r, edge_correction = c("none", "safe"), bounds = NULL)

Value

A numeric vector containing the count of conspecific trees within the radius for each focal tree.

Arguments

sp

A character vector of species names.

gx

A numeric vector of x-coordinates for the trees.

gy

A numeric vector of y-coordinates for the trees.

r

A numeric scalar for the radius parameter.

edge_correction

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

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], 100, replace = TRUE),
  gx = runif(100, 0, 10),
  gy = runif(100, 0, 10)
)
count_con(
  sp = sample_data$latin,
  gx = sample_data$gx,
  gy = sample_data$gy,
  r = 3
)

Run the code above in your browser using DataLab