Skip to content

Commit 2ce080e

Browse files
committed
Switched back to interp rather than interpolation
1 parent 4caada8 commit 2ce080e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Imports:
2323
evd,
2424
ggplot2 (>= 3.1.1),
2525
grDevices,
26-
interpolation,
26+
interp,
2727
ks,
2828
lookout,
2929
mvtnorm,

Diff for: R/dist_kde.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,17 @@ density.dist_kde <- function(x, at, ..., na.rm = TRUE) {
101101
if (d == 1) {
102102
d <- stats::approx(x$kde$eval.points, x$kde$estimate, xout = at)$y
103103
} else {
104-
# Bivariate interpolation
105-
grid <- expand.grid(x$kde$eval.points[[1]], x$kde$eval.points[[2]])
106-
ifun <- interpolation::interpfun(x = grid[, 1], y = grid[, 2], z = c(x$kde$estimate))
107104
# Turn at into a matrix
108105
if (is.list(at)) {
109106
at <- do.call(rbind, at)
110107
} else {
111108
at <- matrix(at, ncol = d)
112109
}
113-
d <- ifun(at[, 1], at[, 2])
110+
# Bivariate interpolation
111+
grid <- expand.grid(x$kde$eval.points[[1]], x$kde$eval.points[[2]])
112+
d <- interp::interpp(x = grid[,1], y = grid[,2], z = c(x$kde$estimate),
113+
xo = at[,1], yo = at[,2])$z |>
114+
suppressWarnings()
114115
}
115116
d[is.na(d)] <- 0
116117
return(d)

0 commit comments

Comments
 (0)