Learn R Programming

topolow (version 1.0.0)

calculate_annual_distances: Calculate Annual Distance Metrics

Description

Calculates year-over-year antigenic distances and statistics. Compares each point to the mean coordinates of the previous year.

Usage

calculate_annual_distances(df_coords, ndim, na.rm = TRUE)

Value

A list containing year-over-year antigenic distance metrics:

dist_data

A data.frame where each row represents a point and its distance to the mean coordinate of the previous year.

summary

A list containing the overall_mean and overall_sd (standard deviation) of the annual distances across all years.

Arguments

df_coords

Data frame containing: - V1...Vn coordinate columns - year: Numeric years - name: Point identifiers (will use rownames if missing)

ndim

Number of coordinate dimensions

na.rm

Logical indicating whether to remove NA values

Examples

Run this code
# Create sample coordinate data
coords <- data.frame(V1 = rnorm(10), V2 = rnorm(10), year = rep(2000:2004, 2))
annual_stats <- calculate_annual_distances(coords, ndim=2)
print(annual_stats$summary$overall_mean)

Run the code above in your browser using DataLab