-
Notifications
You must be signed in to change notification settings - Fork 418
Closed
Description
When using separate_wider_delim
with a sf
object, the function misbehaves and returns a tibble. If using separate
the class of the sf
object is retained. The same issue was documented in issue #1495 but no reprex was provided. This is using v1.3.0 of tidyr
See reprex:
# load packages
suppressPackageStartupMessages({
library(crawl) # loaded for example sf object
library(sf) # load sf
library(tidyr) # load separate functions
})
# load harbor seal data
data("harborSeal_sf")
# check out the sf object
class(harborSeal_sf)
#> [1] "sf" "data.frame"
# make up fake column to separate
harborSeal_sf$fake <- "test_1"
# now use separate_wide_delim
er <- harborSeal_sf |>
separate_wider_delim(cols = fake, names = c("fake", "num"), delim = "_")
class(er)
#> [1] "tbl_df" "tbl" "data.frame"
# returns tibble not a sf object so it changes the object's class
# if we use separate it keeps the objects class
cr <- harborSeal_sf |>
separate(col = fake, into = c("fake", "num"), sep = "_")
class(cr)
#> [1] "sf" "data.frame"
Created on 2023-05-11 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels