scale_coords_df: Scale coordinate variable pairs

View source: R/s.R

scale_coords_dfR Documentation

Scale coordinate variable pairs

Description

Scales coordinate variable pairs in a data.frame by multiplying them with a scale factor.

Usage

scale_coords_df(
  df,
  scale_fct = 1,
  coord_vars = list(pair1 = c("x", "y"), pair2 = c("xend", "yend"), pair3 = c("col",
    "row"), pair4 = c("imagecol", "imagerow")),
  verbose = FALSE,
  error = FALSE,
  ...
)

Arguments

df

Data.frame with numeric coordinate variable pairs.

scale_fct

Numeric value bigger than 0. If used within flipImage() must range between 0 and 1. If only applied to spatial aspects that base on coordinates, can be bigger than 1.

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.