Skip to content

Commit

Permalink
fixes #2333
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Feb 12, 2024
1 parent 0db0bcb commit 5b7e2e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ st_poly_sample = function(x, size, ..., type = "random",
spatstat_fun = try(get(paste0("r", type), asNamespace("spatstat.random")), silent = TRUE)
if (inherits(spatstat_fun, "try-error"))
stop(paste0("r", type), " is not an exported function from spatstat.random.")
pts = try(spatstat_fun(..., win = spatstat.geom::as.owin(x)), silent = TRUE)
pts = if ("win" %in% names(as.list(args(spatstat_fun))))
try(spatstat_fun(..., win = spatstat.geom::as.owin(x)), silent = TRUE)
else
try(spatstat_fun(..., W = spatstat.geom::as.owin(x)), silent = TRUE)
if (inherits(pts, "try-error"))
stop("The spatstat function ", paste0("r", type),
" did not return a valid result. Consult the help file.\n",
Expand Down

0 comments on commit 5b7e2e9

Please sign in to comment.