coords: A simple class for managing lists of coordinates.

Description Usage Arguments Examples

Description

gggeom assumes that every geometry can be represented with a single row of a data frame. This poses a challenge for path and polygon geometries which can be of arbitrary length. To solve this problem, gggeom uses a list-column, where each component of the list is of the same type.

Usage

1
coords(x)

Arguments

x

A list to label as containing coordinates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
make_spiral <- function(turns, r, n = 200) {
  t_grid <- seq(0, turns * 2 * pi, length = n)
  r_grid <- seq(0, r, length = n)
  df <- data.frame(x = r_grid * sin(t_grid), y = r_grid * cos(t_grid))
  render_path(df, ~x, ~y)
}
s1 <- make_spiral(6, 1)
s2 <- make_spiral(-4, 10)

s1
str(s1)
s1$x_

spirals <- rbind(s1, s2)
range(spirals$x_)
spirals %>% plot(col = c("red", "black"))

rstudio/gggeom documentation built on May 28, 2019, 4:35 a.m.