# Generate a sample dataset
set.seed(42) # For reproducibility
sample_data <- data.frame(
latin = sample(letters[1:4], 100, replace = TRUE),
gx = runif(100, 0, 10), # Spatial coordinates between 0 and 10
gy = runif(100, 0, 10),
ba = runif(100, 10, 30) # Basal area between 10 and 30
)
# Calculate with distance weighting
ba_simple(
sp = sample_data$latin,
gx = sample_data$gx,
gy = sample_data$gy,
ba = sample_data$ba,
r = 3, # Radius within the spatial scale
dist_weighted = TRUE
)
# Calculate without distance weighting
ba_simple(
sp = sample_data$latin,
gx = sample_data$gx,
gy = sample_data$gy,
ba = sample_data$ba,
r = 3,
dist_weighted = FALSE
)
Run the code above in your browser using DataLab