Skip to content

Commit

Permalink
check radians
Browse files Browse the repository at this point in the history
  • Loading branch information
robitalec committed Oct 8, 2024
1 parent 6e95c0d commit 01d1b44
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/direction_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ direction_group <- function(
data.table::set(DT, j = out_mean, value = NULL)
}

if (DT[, !inherits(.SD[[1]], 'units'), .SDcols = c(direction)] ||
DT[, units(.SD[[1]])$numerator != 'rad', .SDcols = c(direction)]) {
stop('units(DT$direction) is not radians, did you use direction_step?')
}

DT[, c(out_mean) := units::as_units(
CircStats::circ.mean(units::drop_units(.SD)),
'rad'),
Expand Down

0 comments on commit 01d1b44

Please sign in to comment.