dv_xy2zone | R Documentation |
Convert x, y coordinates to zones
dv_xy2zone(x, y = NULL, as_for_serve = FALSE)
x |
numeric: the x coordinate |
y |
numeric: the y coordinate. If |
as_for_serve |
logical: if |
A numeric vector giving the zone number
dv_xy2index
, dv_index2xy
, dv_cone2xy
, dv_xy2subzone
## Not run:
## a bunch of random points on and around the court
idx <- round(runif(100, min = 1, max = 10000))
## convert to zones
zn <- dv_xy2zone(x = idx)
## or, equivalently, convert the index to xy values first
idx_xy <- dv_index2xy(idx)
zn <- dv_xy2zone(x = idx_xy$x, idx_xy$y)
## plot
ggplot(idx_xy, aes(x, y, fill = as.factor(zn))) + geom_point(shape = 21) +
ggcourt(labels = NULL)
## the points shoud be coloured by zone
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.