map_ids: Map raw tracking IDs to standardized child IDs

View source: R/map_ids.R

map_idsR Documentation

Map raw tracking IDs to standardized child IDs

Description

Map raw tracking IDs to standardized child IDs

Usage

map_ids(
  data,
  mapping,
  exclude_ids = NULL,
  raw_id_col = "ID",
  id_col = "id_code",
  analyze_col = "Analyze"
)

Arguments

data

A data frame with raw tracking data

mapping

Either:

  • Path to CSV file with columns 'raw_id' and 'child_id'

  • Data frame with columns 'raw_id' and 'child_id'

  • Named vector (raw_id = child_id)

exclude_ids

Vector of raw IDs to exclude from analysis (sets Analyze = 0)

raw_id_col

Name of the raw ID column in data (default: "ID")

id_col

Name of the output column for standardized IDs (default: "id_code")

analyze_col

Name of the Analyze column in data (default: "Analyze")

Value

Data frame with added id_code column and updated Analyze column

Examples

raw_data <- data.frame(
  ID = c(1L, 2L, 3L),
  At = as.POSIXct("2025-03-18 11:45:00"),
  X  = c(1.0, 2.0, 3.0),
  Y  = c(1.0, 2.0, 3.0)
)
id_map <- data.frame(raw_id = c(1L, 2L, 3L), child_id = c(5001L, 5002L, 5003L))
data_mapped <- map_ids(raw_data, id_map)

trackclean documentation built on July 1, 2026, 5:07 p.m.