Learn R Programming

duet (version 0.1.1)

op_interpolate: Interpolate missing or low-confidence values in a dataset

Description

This function performs interpolation for x and y coordinate columns in a dataset based on confidence thresholds. It groups the data by person and region and uses spline interpolation to estimate missing or low-confidence values.

Usage

op_interpolate(
  data,
  confidence_threshold,
  missing = TRUE,
  treat_na_conf_as_low = FALSE
)

Value

A modified data frame with interpolated x and y values for low-confidence or missing rows.

Arguments

data

A data frame containing x, y, confidence columns, and grouping columns (person, region).

confidence_threshold

A numeric value specifying the confidence threshold below which values will be interpolated.

missing

Logical. If TRUE, interpolate missing values (NA) in addition to low-confidence values.

treat_na_conf_as_low

Logical. If TRUE, treat NA in the confidence column as low confidence.

Examples

Run this code
# Load example data from the package
data_path <- system.file("extdata/csv_data/A-B_body_dyad.csv", package = "duet")
data <- read.csv(data_path)

# Interpolate missing or low-confidence values
result <- op_interpolate(
  data = data,
  confidence_threshold = 0.5,
  missing = TRUE,
  treat_na_conf_as_low = TRUE
)

print(result)

Run the code above in your browser using DataLab