compute_o_diff: Compute orientation difference

Description Usage Arguments Value Examples

View source: R/cleaning_functions.R

Description

Compute difference in orientation between direction player is currently facing and orientation if player were facing towards a given x and y location.

Usage

1
compute_o_diff(df, prefix = "qb")

Arguments

df

A dataframe containing x, y, o, "prefix"_x, and "prefix"_y

prefix

(default = "qb"). Columns prefix_x and prefix_y must be contained in df. These columns contain the x and y locations that will be used to calculate orientation difference.

Value

Original dataframe with o_to_"prefix" added, which is the difference in orientation in degrees between the way the player is facing and where the "prefix" player is (0 is facing directly at the "prefix" player, 180 is directly away).

Examples

1
2
3
df <- tibble::tibble("x" = 20, "y" = 30, "o" = 270, "qb_x" = 10, "qb_y" = 25)
df <- compute_o_diff(df)
str(df)

guga31bb/ngscleanR documentation built on Dec. 20, 2021, 1:47 p.m.