R/bb_get_one_side.R

#' Get the coordinates for half-court graphics.
#'
#' \code{bb_get_one_side} returns a dataframe which has two new columns representing
#' transformed xy coordinates intended to make half court graphics easier to make.
#'
#' @param data a dataframe
#' @param x_col a column of x coordinates
#' @param y_col a column of y coordinates
#' @keywords bb_get_one_side
#' @export
#'

bb_get_one_side <- function(data, x_col, y_col) {

    # define coordinates of half/full court
    # -------------------------------------
    halfCourt = 470
    fullCourt = 940

    data$x_one_side <- ifelse(data$x > halfCourt,
                                  (fullCourt - data$x),
                                  data$x)

    data$y_one_side <- ifelse(data$x > halfCourt,
                                  (500 - data$y), data$y)

    data
}
mistermichaelll/statcrewRC documentation built on June 1, 2019, 3:57 a.m.