rotate_coordinates: This function takes x and y coordinates and rotates them...

View source: R/CrossExpression.R

rotate_coordinatesR Documentation

This function takes x and y coordinates and rotates them counterclockwise by the specified number of degrees, and mean centers the points.

Description

This function takes x and y coordinates and rotates them counterclockwise by the specified number of degrees, and mean centers the points.

Usage

rotate_coordinates(
  x,
  y,
  n_degrees = 0,
  center = FALSE,
  scale = FALSE,
  flip_x = FALSE,
  flip_y = FALSE
)

Arguments

x

The x coordinates.

y

The y coordinates.

n_degrees

The degree of rotation in counterclockwise direction.

center

If TRUE, mean centers the points.

scale

If TRUE, standardizes the points.

flip_x

Reflects the points across y = 0 line.

flip_y

Reflects the points across x = 0 line.

Value

Returns a data frame containing the new x and y coordinates.

Examples

data("locations")
locations = as.data.frame(as.matrix(locations))
ggplot2::ggplot(data = locations) + ggplot2::aes(x = pos_x, y = pos_y) +
  ggplot2::geom_point(size = 0) + ggplot2::theme_classic()

locations = rotate_coordinates(x = locations$pos_x, y = locations$pos_y, n_degrees = 45)
ggplot2::ggplot(data = locations) + ggplot2::aes(x = pos_x, y = pos_y) +
  ggplot2::geom_point(size = 0) + ggplot2::theme_classic()


CrossExpression documentation built on Aug. 8, 2025, 7:25 p.m.