Skip to content

Commit 5b7e2e9

Browse files
committed
fixes #2333
1 parent 0db0bcb commit 5b7e2e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

R/sample.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ st_poly_sample = function(x, size, ..., type = "random",
262262
spatstat_fun = try(get(paste0("r", type), asNamespace("spatstat.random")), silent = TRUE)
263263
if (inherits(spatstat_fun, "try-error"))
264264
stop(paste0("r", type), " is not an exported function from spatstat.random.")
265-
pts = try(spatstat_fun(..., win = spatstat.geom::as.owin(x)), silent = TRUE)
265+
pts = if ("win" %in% names(as.list(args(spatstat_fun))))
266+
try(spatstat_fun(..., win = spatstat.geom::as.owin(x)), silent = TRUE)
267+
else
268+
try(spatstat_fun(..., W = spatstat.geom::as.owin(x)), silent = TRUE)
266269
if (inherits(pts, "try-error"))
267270
stop("The spatstat function ", paste0("r", type),
268271
" did not return a valid result. Consult the help file.\n",

0 commit comments

Comments
 (0)