Skip to content

Unexpected behavior of str_trunc #203

@bguiastr

Description

@bguiastr

I encountered an unexpected behavior of str_trunc(), here is a reprex of my problem.

In stringr v1.2.0 the result is as expected:

str_trunc(c('abcd', 'abcde', 'abcdef'), width = 5)
[1] "abcd"  "abcde" "ab..."

In stringr v1.2.0.9000 the result not what one would unexpect:

str_trunc(c('abcd', 'abcde', 'abcdef'), width = 5)
[1] "abcd"   "abcde"  "abcdef"

And changing the order of the elements of the vector also impacts the output, which leads me to believe that the truncation is performed or not based on the number of characters in the first element of the vector of strings

str_trunc(c('abcdef', 'abcde', 'abcd'), width = 5)
[1] "ab..." "ab..." "ab..."

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