-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling tibble::rowid_to_column on an object of class "sf" before dplyr::rename will cause " internal error: can't find agr columns" #1552
Comments
This seems to be the underlying issue: options(conflicts.policy = list(warn = FALSE))
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(dplyr)
input <- read_sf(system.file("shape/nc.shp", package = "sf"))
x1 <-
input |>
dplyr::mutate(var = row_number(), .before = 1)
x2 <-
input |>
tibble::rowid_to_column("var")
waldo::compare(x1, x2)
#> `names(attr(old, 'agr'))[1:4]`: "var" "AREA" "PERIMETER" "CNTY_"
#> `names(attr(new, 'agr'))[1:3]`: "AREA" "PERIMETER" "CNTY_"
#>
#> `attr(old, 'agr')[12:15]`: "NA" "NA" "NA" "NA"
#> `attr(new, 'agr')[12:14]`: "NA" "NA" "NA" Created on 2023-08-15 with reprex v2.0.2 I don't know about the semantics of the |
Removing the call to |
Thanks. I agree that it's not this function's business to call |
Over the last years, various variants were tried to preserve the |
I reported this on the sf repo where Edzer remarked that it was an issue with
rowid_to_column
messing up theagr
attribute.So I thought I would report it here.
I use this in my spatial workflow quite often, so I was wondering if it is possible to fix somehow? There are workarounds of course, but if that could be avoided it would be great!
Issue on the sf repo is here
Created on 2023-08-15 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: