rotate_coords_df: Rotate coordinate variables pairs

View source: R/r.R

rotate_coords_dfR Documentation

Rotate coordinate variables pairs

Description

Rotates coordinate variable pairs in a data.frame.

Usage

rotate_coords_df(
  df,
  angle,
  clockwise = TRUE,
  coord_vars = list(pair1 = c("x", "y"), pair2 = c("xend", "yend")),
  verbose = FALSE,
  error = FALSE,
  center = c(0, 0),
  ...
)

Arguments

df

Data.frame with numeric coordinate variable pairs.

angle

Numeric value. The angle by which the coordinates are rotated. Should range from 1-359.

clockwise

Logical value. If TRUE, rotation is performed in clockwise direction. If FALSE, the other way round.

coord_vars

Input that denotes the variable pairs. Can be a vector of length two. Or a list of vectors of length two. First element in vector sets name for the x-axis, second value sets name for the y axis.

If a list is provided, each slot is checked and invalid slots are removed from the iteration.

verbose

Logical. If set to TRUE informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

error

Logical. If TRUE and the input is invalid the function throws an error.

...

Additional arguments given to give_feedback().

Details

Usually a data.frame that contains variables that refer to x- and y-coordinates has one single pair of these. E.g. one variable named x and one variable named y. If so, coord_vars = c("x", "y") or ⁠coord_vars = list(pair1 = c("x", "y")⁠ is appropriate (naming the list is not necessary). If the data.frame contains several variables that refer to the same axes but in different scales they can be adjusted altogether. E.g. a data.frame that contains variable pair x and y as well as col and row needs ⁠coord_vars = list(pair1 = c("x", "y"), pair2 = c("col", "row")⁠. For a pair to be adjusted both variables must be found, else the adjustment is skipped and the function gives feedback if verbose = TRUE or throws an error if error = TRUE. Default sets both to FALSE which results in silent skipping.

Value

Adjusted data.frame.


kueckelj/SPATA2 documentation built on March 16, 2024, 10:25 a.m.