View source: R/circular_functions.R
circ_minus | R Documentation |
Calculate the circular subtraction x - y
circ_minus(x, y, int, type = c("minusPiPlusPi", "ZeroPlus2Pi"))
x |
A numeric vector or array. |
y |
A numeric vector or array. |
int |
A numeric value. The number of units of |
type |
A character string. If |
# Days of year
circ_minus(260, 240, int = 365) ## expected: +20
circ_minus(240, 260, int = 365) ## expected: -20
circ_minus(240, 260, int = 365, type = "ZeroPlus2Pi") ## expected: 345
circ_minus(10, 360, int = 365) ## expected: +15
circ_minus(360, 10, int = 365) ## expected: -15
circ_minus(360, 10, int = 365, type = "ZeroPlus2Pi") ## expected: 350
circ_minus(0, 360, int = 365) ## expected: +5
circ_minus(360, 0, int = 365) ## expected: -5
circ_minus(360, 0, int = 365, type = "ZeroPlus2Pi") ## expected: 360
# Matrix examples
x <- matrix(c(260, 240, 10, 360, 0, 360), nrow = 3, ncol = 2)
y <- matrix(c(240, 260, 360, 10, 360, 0), nrow = 3, ncol = 2)
circ_minus(x, y, int = 365)
y2 <- y
y2[1, 1] <- NA
circ_minus(y2, x, int = 365)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.