Skip to content
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

separate_wider_delim function remove sf class and return tibble #1498

Closed
benjaminhlina opened this issue May 11, 2023 · 3 comments
Closed

separate_wider_delim function remove sf class and return tibble #1498

benjaminhlina opened this issue May 11, 2023 · 3 comments

Comments

@benjaminhlina
Copy link

benjaminhlina commented May 11, 2023

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

@benjaminhlina benjaminhlina changed the title new sepearate_wide_delim functions remove sf class and return tibble new separate_wider_delim functions remove sf class and return tibble May 11, 2023
@benjaminhlina benjaminhlina changed the title new separate_wider_delim functions remove sf class and return tibble separate_wider_delim functions remove sf class and return tibble May 15, 2023
@benjaminhlina benjaminhlina changed the title separate_wider_delim functions remove sf class and return tibble separate_wider_delim function remove sf class and return tibble May 15, 2023
@benjaminhlina
Copy link
Author

benjaminhlina commented Mar 13, 2024

What is the status of this @hadley? This seems to still be an issue along with multiple issues with the newer version of separate_. I understand the rational for the newer functions and enjoy the multiple features (e.g., too_few/too_many) they have, just feel the idea to push superseded on seperate() was premature considering the multiple issues the new functions face.

@olivroy
Copy link
Contributor

olivroy commented Mar 13, 2024

The issue is probably with sf, as it doesn't provide a separate_wider_delim() method. https://r-spatial.github.io/sf/reference/tidyverse.html

@benjaminhlina
Copy link
Author

Thanks @olivroy for the response. That overall makes sense, sorry I directed the issue at {tidyr} and not {sf}. I'll close this issue and open one on their end. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants