Skip to content

Commit 4ba1f3c

Browse files
committed
avoid NextMethod() in [.sfc (too many revdeps break)
1 parent e5d79c8 commit 4ba1f3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

R/sfc.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ st_sfc = function(..., crs = NA_crs_, precision = 0.0, check_ring_dir = FALSE, d
153153
precision = st_precision(x)
154154
crs = st_crs(x)
155155
dim = if (length(x)) class(x[[1]])[1] else "XY"
156-
if (!missing(i) && (inherits(i, "sf") || inherits(i, "sfc") || inherits(i, "sfg"))) {
156+
if (!missing(i) && (inherits(i, c("sf", "sfc", "sfg"))))
157157
i = lengths(op(x, i, ...)) != 0
158-
st_sfc(unclass(x)[i], crs = crs, precision = precision, dim = dim)
159-
} else
158+
if (!is.null(dim(x))) # x is an array with geometries
160159
st_sfc(NextMethod(), crs = crs, precision = precision, dim = dim)
160+
else # x is a list but avoid NextMethod() to allow j, ... to be specified & ignored:
161+
st_sfc(unclass(x)[i], crs = crs, precision = precision, dim = dim)
161162
}
162163

163164
#' @export

0 commit comments

Comments
 (0)