diff_rad | R Documentation |
Internal function
diff_rad(x, y, signed = FALSE, return_units = FALSE)
x |
angle in radians |
y |
angle in radians |
signed |
boolean if signed difference should be returned, default FALSE |
return_units |
return difference with units = 'rad' |
Difference between x and y in radians. If signed is TRUE, the signed difference is returned. If signed is FALSE, the absolute difference is returned. Note: The difference is the smallest difference, eg.
adapted from https://stackoverflow.com/a/7869457
# Load data.table
library(data.table)
# Read example data
DT <- fread(system.file("extdata", "DT.csv", package = "spatsoc"))
# Cast the character column to POSIXct
DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
# Set order using data.table::setorder
setorder(DT, datetime)
# Calculate direction
direction_step(
DT = DT,
id = 'ID',
coords = c('X', 'Y'),
projection = 32736
)
# Differences
spatsoc:::diff_rad(DT[1, direction], DT[2, direction])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.