-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Description
I just noticed assigning a column in a grouped sf drops the sf class:
require(sf)
#> Loading required package: sf
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
require(dplyr)
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
data(meuse, package = "sp")
meuse_sf = st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant")
meuse_grp<-meuse_sf |> group_by(landuse)
class(meuse_grp)
#> [1] "sf" "grouped_df" "tbl_df" "tbl" "data.frame"
meuse_grp[,"new"] <-1:155
class(meuse_grp)
#> [1] "grouped_df" "tbl_df" "tbl" "data.frame"
sessioninfo::package_info("attached")
#> package * version date (UTC) lib source
#> dplyr * 1.1.3 2023-09-03 [1] CRAN (R 4.3.1)
#> sf * 1.0-15 2023-12-18 [1] CRAN (R 4.3.2)
#>
#> [1] /home/bart/R/x86_64-pc-linux-gnu-library/4.3
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/libraryCreated on 2024-01-30 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels