Giter VIP home page Giter VIP logo

Comments (6)

bartektartanus avatar bartektartanus commented on June 6, 2024

//To determine: which option is better/more logical/etc
strsplit("lalal","l")
[[1]]
[1] "" "a" "a"
//or
stri_split("lalal","l")
[[1]]
[1] "" "a" "a" ""
// The R developers are aware of this:
// Note that final empty strings are not produced:
strsplit(paste(c("", "a", ""), collapse="#"), split="#")[[1]]
// [1] "" "a"

//But why the last empty space is treated less serious? If we get first empty space, why not last one too?

--edit--
str_split works like this:

str_split("lalal","l")
[[1]]
[1] "" "a" "a" ""

//added one line into stri_split, so now it works like strsplit (if last element of character vector is "" it won't be returned)

from stringi.

gagolews avatar gagolews commented on June 6, 2024

maybe we could omit all empty strings by default, but also introduce an option that forces leaving them as they are?

from stringi.

bartektartanus avatar bartektartanus commented on June 6, 2024

stri_split(NA_character_,"A")
[[1]]
[1] "N" ""

TODO: correct this wrong behavior

from stringi.

gagolews avatar gagolews commented on June 6, 2024

Please note that str_split has additional, very useful argument: n - it returns a matrix with n columns :-)

from stringi.

bartektartanus avatar bartektartanus commented on June 6, 2024

`> str_split(c("ala","ma kota"),"a",2)
[[1]]
[1] "" "l"

[[2]]
[1] "m" " kot" `
Nope, it's still list.

That won't be so hard to do. I'll do this tomorrow :)

from stringi.

gagolews avatar gagolews commented on June 6, 2024

DONE yesterday :>

from stringi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.