Skip to content

Commit

Permalink
bug fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiste committed Aug 4, 2024
1 parent c2a2748 commit 18b9f4b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions R/interpolation.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ stress2grid <- function(x,
# lat.Y <- lon.X <- numeric(nrow(SH)) # pre allocating
res <- dplyr::as_tibble(SH) |>
# dplyr::rename(lon = lon.X, lat = lat.Y) |>
dplyr::mutate(N = as.integer(N), sd = sd/2, mdr = md / R) |>
dplyr::mutate(N = as.integer(N), sd = sd / 2, mdr = md / R) |>
dplyr::select(-md) |>
dplyr::filter(!is.na(azi), sd <= threshold, !is.na(sd)) |>
sf::st_as_sf(coords = c("lon", "lat"), crs = sf::st_crs(x), remove = FALSE)
Expand Down Expand Up @@ -614,7 +614,6 @@ kernel_dispersion <- function(x,
)

SH <- rbind(SH, SH.ik)

}
}
}
Expand Down
4 changes: 1 addition & 3 deletions R/preliminary.R
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,6 @@ watson_test_boot <- function(x, mu = NULL, w = NULL, axial = TRUE, alpha = NULL,
#' @examples
#' x <- rvm(100, 0, 5)
#' as.circ(x)
as.circ <- function(x, axial = TRUE){
as.circ <- function(x, axial = TRUE) {
circular::circular(x, units = "degrees", modulo = "asis")
}


6 changes: 3 additions & 3 deletions R/statistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' x <- rvm(100, 0, 5)
#' mean_SC(x)
#' }
mean_SC <- function(x, w=NULL, na.rm=TRUE) {
mean_SC <- function(x, w = NULL, na.rm = TRUE) {
stopifnot(any(is.numeric(x)), is.logical(na.rm))

w <- if (is.null(w)) {
Expand Down Expand Up @@ -40,7 +40,7 @@ mean_SC <- function(x, w=NULL, na.rm=TRUE) {
#
# sums <- colSums(cbind(cosx, sinx))
sums <- c(sum(cosx), sum(sinx))
setNames(sums/Z, nm=c('C', 'S'))
setNames(sums / Z, nm = c("C", "S"))
}


Expand Down Expand Up @@ -151,7 +151,7 @@ NULL
#' @rdname circle_stats
#' @export
circular_mean <- function(x, w = NULL, axial = TRUE, na.rm = TRUE) {
if(axial){
if (axial) {
f <- 2
} else {
f <- 1
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_that.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ sa.por <- PoR_shmax(san_andreas, na_pa, "right")
test_that("Compe to {circular} package", {
expect_equal(
circular_mean(sa.por$azi.PoR),
((circular::mean.circular(as.circ(2*sa.por$azi.PoR)) |> as.numeric()/2) %% 180)
((circular::mean.circular(circular::circular(2 * sa.por$azi.PoR, units = "degrees", modulo = "asis")) |> as.numeric() / 2) %% 180)
)
})

Expand Down

0 comments on commit 18b9f4b

Please sign in to comment.