# NOT RUN { g = st_sfc(st_point(1:2)) st_sf(a=3,g) st_sf(g, a=3) st_sf(a=3, st_sfc(st_point(1:2))) # better to name it! # create empty structure with preallocated empty geometries: nrows <- 10 geometry = st_sfc(lapply(1:nrows, function(x) st_geometrycollection())) df <- st_sf(id = 1:nrows, geometry = geometry) g = st_sfc(st_point(1:2), st_point(3:4)) s = st_sf(a=3:4, g) s[1,] class(s[1,]) s[,1] class(s[,1]) s[,2] class(s[,2]) g = st_sf(a=2:3, g) pol = st_sfc(st_polygon(list(cbind(c(0,3,3,0,0),c(0,0,3,3,0))))) h = st_sf(r = 5, pol) g[h,] h[g,] # }
Run the code above in your browser using DataCamp Workspace