Skip to content

Separate_rows in v1.1.1 doesn't seem to work the same as in v1.1.0 #1014

@alexeyza

Description

@alexeyza

There are inconsistencies in how separate_rows works in version 1.1.1 compared to version 1.1.0. I noticed it when my code that was working in 1.1.0 was now returning errors due to empty data.frames and other errors (in 1.1.1).

# reprex (version 1.1.0)

> iris %>% separate_rows(Species, sep = ";")
# A tibble: 150 x 5
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
 1          5.1         3.5          1.4         0.2 setosa 
 2          4.9         3            1.4         0.2 setosa 
 3          4.7         3.2          1.3         0.2 setosa 
 4          4.6         3.1          1.5         0.2 setosa 
 5          5           3.6          1.4         0.2 setosa 
 6          5.4         3.9          1.7         0.4 setosa 
 7          4.6         3.4          1.4         0.3 setosa 
 8          5           3.4          1.5         0.2 setosa 
 9          4.4         2.9          1.4         0.2 setosa 
10          4.9         3.1          1.5         0.1 setosa 
# … with 140 more rows
# reprex (version 1.1.1)

> iris %>% separate_rows(Species, sep = ";")
Error in .f(.x[[i]], ...) : non-character argument

Also, try both versions on a dataframe with a column of empty strings in it:

iris %>% mutate(test = "") %>% separate_rows(test, sep = ";")

In version 1.1.0 it returns the full original dataframe, while in version 1.1.1 it returns an empty dataframe.


From a quick glimpse on recent changes, I think it comes down to the following change:
f0bcfd9#diff-46dad93d5ee31264d672c8ed8c984258

I tried to see what could be the source for the difference by looking at:

> stringi::stri_split_regex(str="", pattern = ";")
[[1]]
[1] ""

> strsplit("", split = ";", perl = T)
[[1]]
character(0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions